e9fd0694e3c73e206f870aadd23324d9af3e9b74
[android-sdk/device-ti-proprietary-open.git] / omap5 / sgx_src / eurasia_km / services4 / system / omap4 / sysconfig.c
1 /*************************************************************************/ /*!
2 @Title System Configuration
3 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 @Description System Configuration functions
5 @License Dual MIT/GPLv2
7 The contents of this file are subject to the MIT license as set out below.
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
19 Alternatively, the contents of this file may be used under the terms of
20 the GNU General Public License Version 2 ("GPL") in which case the provisions
21 of GPL are applicable instead of those above.
23 If you wish to allow use of your version of this file only under the terms of
24 GPL, and not to allow others to use your version of this file under the terms
25 of the MIT license, indicate your decision by deleting the provisions above
26 and replace them with the notice and other provisions required by GPL as set
27 out in the file called "GPL-COPYING" included in this distribution. If you do
28 not delete the provisions above, a recipient may use your version of this file
29 under the terms of either the MIT license or GPL.
31 This License is also included in this distribution in the file called
32 "MIT-COPYING".
34 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
35 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
38 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 */ /**************************************************************************/
43 #include "sysconfig.h"
44 #include "services_headers.h"
45 #include "kerneldisplay.h"
46 #include "oemfuncs.h"
47 #include "sgxinfo.h"
48 #include "sgxinfokm.h"
49 #include "syslocal.h"
51 #include "ocpdefs.h"
53 #define OMAP5430_CORE_REV 0x10005
55 /* top level system data anchor point*/
56 SYS_DATA* gpsSysData = (SYS_DATA*)IMG_NULL;
57 SYS_DATA gsSysData;
59 static SYS_SPECIFIC_DATA gsSysSpecificData;
60 SYS_SPECIFIC_DATA *gpsSysSpecificData;
62 /* SGX structures */
63 static IMG_UINT32 gui32SGXDeviceID;
64 static SGX_DEVICE_MAP gsSGXDeviceMap;
65 static PVRSRV_DEVICE_NODE *gpsSGXDevNode;
68 #if defined(NO_HARDWARE) || defined(SGX_OCP_REGS_ENABLED)
69 static IMG_CPU_VIRTADDR gsSGXRegsCPUVAddr;
70 #endif
72 #if defined(PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO)
73 extern struct platform_device *gpsPVRLDMDev;
74 #endif
76 IMG_UINT32 PVRSRV_BridgeDispatchKM(IMG_UINT32 Ioctl,
77 IMG_BYTE *pInBuf,
78 IMG_UINT32 InBufLen,
79 IMG_BYTE *pOutBuf,
80 IMG_UINT32 OutBufLen,
81 IMG_UINT32 *pdwBytesTransferred);
83 #if defined(SGX_OCP_REGS_ENABLED)
85 static IMG_CPU_VIRTADDR gpvOCPRegsLinAddr;
87 static PVRSRV_ERROR EnableSGXClocksWrap(SYS_DATA *psSysData)
88 {
89 PVRSRV_ERROR eError = EnableSGXClocks(psSysData);
91 #if !defined(SGX_OCP_NO_INT_BYPASS)
92 if(eError == PVRSRV_OK)
93 {
94 OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_SYSCONFIG, 0x14);
95 OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_DEBUG_CONFIG, EUR_CR_OCP_DEBUG_CONFIG_THALIA_INT_BYPASS_MASK);
96 }
97 #endif
98 return eError;
99 }
101 #else /* defined(SGX_OCP_REGS_ENABLED) */
103 static INLINE PVRSRV_ERROR EnableSGXClocksWrap(SYS_DATA *psSysData)
104 {
105 return EnableSGXClocks(psSysData);
106 }
108 #endif /* defined(SGX_OCP_REGS_ENABLED) */
110 static INLINE PVRSRV_ERROR EnableSystemClocksWrap(SYS_DATA *psSysData)
111 {
112 PVRSRV_ERROR eError = EnableSystemClocks(psSysData);
114 #if !defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
115 if(eError == PVRSRV_OK)
116 {
117 /*
118 * The SGX Clocks are enabled separately if active power
119 * management is enabled.
120 */
121 eError = EnableSGXClocksWrap(psSysData);
122 if (eError != PVRSRV_OK)
123 {
124 DisableSystemClocks(psSysData);
125 }
126 }
127 #endif
129 return eError;
130 }
132 /*!
133 ******************************************************************************
135 @Function SysLocateDevices
137 @Description Specifies devices in the systems memory map
139 @Input psSysData - sys data
141 @Return PVRSRV_ERROR
143 ******************************************************************************/
144 static PVRSRV_ERROR SysLocateDevices(SYS_DATA *psSysData)
145 {
146 #if defined(NO_HARDWARE)
147 PVRSRV_ERROR eError;
148 IMG_CPU_PHYADDR sCpuPAddr;
149 #else
150 #if defined(PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO)
151 struct resource *dev_res;
152 int dev_irq;
153 #endif
154 #endif
156 PVR_UNREFERENCED_PARAMETER(psSysData);
158 /* SGX Device: */
159 gsSGXDeviceMap.ui32Flags = 0x0;
161 #if defined(NO_HARDWARE)
162 /*
163 * For no hardware, allocate some contiguous memory for the
164 * register block.
165 */
167 /* Registers */
168 gsSGXDeviceMap.ui32RegsSize = SYS_OMAP4430_SGX_REGS_SIZE;
170 eError = OSBaseAllocContigMemory(gsSGXDeviceMap.ui32RegsSize,
171 &gsSGXRegsCPUVAddr,
172 &sCpuPAddr);
173 if(eError != PVRSRV_OK)
174 {
175 return eError;
176 }
177 gsSGXDeviceMap.sRegsCpuPBase = sCpuPAddr;
178 gsSGXDeviceMap.sRegsSysPBase = SysCpuPAddrToSysPAddr(gsSGXDeviceMap.sRegsCpuPBase);
179 #if defined(__linux__)
180 /* Indicate the registers are already mapped */
181 gsSGXDeviceMap.pvRegsCpuVBase = gsSGXRegsCPUVAddr;
182 #else
183 /*
184 * FIXME: Could we just use the virtual address returned by
185 * OSBaseAllocContigMemory?
186 */
187 gsSGXDeviceMap.pvRegsCpuVBase = IMG_NULL;
188 #endif
190 OSMemSet(gsSGXRegsCPUVAddr, 0, gsSGXDeviceMap.ui32RegsSize);
192 /*
193 device interrupt IRQ
194 Note: no interrupts available on no hardware system
195 */
196 gsSGXDeviceMap.ui32IRQ = 0;
198 #else /* defined(NO_HARDWARE) */
199 #if defined(PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO)
200 /* get the resource and IRQ through platform resource API */
201 dev_res = platform_get_resource(gpsPVRLDMDev, IORESOURCE_MEM, 0);
202 if (dev_res == NULL)
203 {
204 PVR_DPF((PVR_DBG_ERROR, "%s: platform_get_resource failed", __FUNCTION__));
205 return PVRSRV_ERROR_INVALID_DEVICE;
206 }
208 dev_irq = platform_get_irq(gpsPVRLDMDev, 0);
209 if (dev_irq < 0)
210 {
211 PVR_DPF((PVR_DBG_ERROR, "%s: platform_get_irq failed (%d)", __FUNCTION__, -dev_irq));
212 return PVRSRV_ERROR_INVALID_DEVICE;
213 }
215 gsSGXDeviceMap.sRegsSysPBase.uiAddr = dev_res->start;
216 gsSGXDeviceMap.sRegsCpuPBase =
217 SysSysPAddrToCpuPAddr(gsSGXDeviceMap.sRegsSysPBase);
218 PVR_TRACE(("SGX register base: 0x%lx", (unsigned long)gsSGXDeviceMap.sRegsCpuPBase.uiAddr));
220 #if defined(SGX544) && defined(SGX_FEATURE_MP)
221 /* Workaround: Due to the change in the HWMOD, the driver is only detecting the
222 size of the first memory section. For the moment, set the size with a macro
223 until a better solution found */
224 gsSGXDeviceMap.ui32RegsSize = SYS_OMAP4430_SGX_REGS_SIZE;
225 #else
226 gsSGXDeviceMap.ui32RegsSize = (unsigned int)(dev_res->end - dev_res->start);
227 #endif
229 PVR_TRACE(("SGX register size: %d",gsSGXDeviceMap.ui32RegsSize));
231 gsSGXDeviceMap.ui32IRQ = dev_irq;
232 PVR_TRACE(("SGX IRQ: %d", gsSGXDeviceMap.ui32IRQ));
233 #else /* defined(PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO) */
234 gsSGXDeviceMap.sRegsSysPBase.uiAddr = SYS_OMAP4430_SGX_REGS_SYS_PHYS_BASE;
235 gsSGXDeviceMap.sRegsCpuPBase = SysSysPAddrToCpuPAddr(gsSGXDeviceMap.sRegsSysPBase);
236 gsSGXDeviceMap.ui32RegsSize = SYS_OMAP4430_SGX_REGS_SIZE;
238 gsSGXDeviceMap.ui32IRQ = SYS_OMAP4430_SGX_IRQ;
240 #endif /* defined(PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO) */
241 #if defined(SGX_OCP_REGS_ENABLED)
242 gsSGXRegsCPUVAddr = OSMapPhysToLin(gsSGXDeviceMap.sRegsCpuPBase,
243 gsSGXDeviceMap.ui32RegsSize,
244 PVRSRV_HAP_UNCACHED|PVRSRV_HAP_KERNEL_ONLY,
245 IMG_NULL);
247 if (gsSGXRegsCPUVAddr == IMG_NULL)
248 {
249 PVR_DPF((PVR_DBG_ERROR,"SysLocateDevices: Failed to map SGX registers"));
250 return PVRSRV_ERROR_BAD_MAPPING;
251 }
253 /* Indicate the registers are already mapped */
254 gsSGXDeviceMap.pvRegsCpuVBase = gsSGXRegsCPUVAddr;
255 gpvOCPRegsLinAddr = gsSGXRegsCPUVAddr;
256 #endif
257 #endif /* defined(NO_HARDWARE) */
259 #if defined(PDUMP)
260 {
261 /* initialise memory region name for pdumping */
262 static IMG_CHAR pszPDumpDevName[] = "SGXMEM";
263 gsSGXDeviceMap.pszPDumpDevName = pszPDumpDevName;
264 }
265 #endif
267 /* add other devices here: */
270 return PVRSRV_OK;
271 }
274 /*!
275 ******************************************************************************
277 @Function SysCreateVersionString
279 @Description Read the version string
281 @Return IMG_CHAR * : Version string
283 ******************************************************************************/
284 static IMG_CHAR *SysCreateVersionString(void)
285 {
286 static IMG_CHAR aszVersionString[100];
287 SYS_DATA *psSysData;
288 IMG_UINT32 ui32SGXRevision;
289 IMG_INT32 i32Count;
290 #if !defined(NO_HARDWARE)
291 IMG_VOID *pvRegsLinAddr;
293 pvRegsLinAddr = OSMapPhysToLin(gsSGXDeviceMap.sRegsCpuPBase,
294 gsSGXDeviceMap.ui32RegsSize,
295 PVRSRV_HAP_UNCACHED|PVRSRV_HAP_KERNEL_ONLY,
296 IMG_NULL);
297 if(!pvRegsLinAddr)
298 {
299 return IMG_NULL;
300 }
302 #if defined(SGX544) && defined(SGX_FEATURE_MP)
303 ui32SGXRevision = OMAP5430_CORE_REV;
304 #else
305 ui32SGXRevision = OSReadHWReg((IMG_PVOID)((IMG_PBYTE)pvRegsLinAddr),
306 EUR_CR_CORE_REVISION);
307 #endif
309 #else
310 ui32SGXRevision = 0;
311 #endif
313 SysAcquireData(&psSysData);
315 i32Count = OSSNPrintf(aszVersionString, 100,
316 "SGX revision = %u.%u.%u",
317 (IMG_UINT)((ui32SGXRevision & EUR_CR_CORE_REVISION_MAJOR_MASK)
318 >> EUR_CR_CORE_REVISION_MAJOR_SHIFT),
319 (IMG_UINT)((ui32SGXRevision & EUR_CR_CORE_REVISION_MINOR_MASK)
320 >> EUR_CR_CORE_REVISION_MINOR_SHIFT),
321 (IMG_UINT)((ui32SGXRevision & EUR_CR_CORE_REVISION_MAINTENANCE_MASK)
322 >> EUR_CR_CORE_REVISION_MAINTENANCE_SHIFT)
323 );
325 #if !defined(NO_HARDWARE)
326 OSUnMapPhysToLin(pvRegsLinAddr,
327 SYS_OMAP4430_SGX_REGS_SIZE,
328 PVRSRV_HAP_UNCACHED|PVRSRV_HAP_KERNEL_ONLY,
329 IMG_NULL);
330 #endif
332 if(i32Count == -1)
333 {
334 return IMG_NULL;
335 }
337 return aszVersionString;
338 }
341 /*!
342 ******************************************************************************
344 @Function SysInitialise
346 @Description Initialises kernel services at 'driver load' time
348 @Return PVRSRV_ERROR :
350 ******************************************************************************/
351 PVRSRV_ERROR SysInitialise(IMG_VOID)
352 {
353 IMG_UINT32 i;
354 PVRSRV_ERROR eError;
355 PVRSRV_DEVICE_NODE *psDeviceNode;
356 #if !defined(PVR_NO_OMAP_TIMER)
357 IMG_CPU_PHYADDR TimerRegPhysBase;
358 #endif
359 #if !defined(SGX_DYNAMIC_TIMING_INFO)
360 SGX_TIMING_INFORMATION* psTimingInfo;
361 #endif
362 gpsSysData = &gsSysData;
363 OSMemSet(gpsSysData, 0, sizeof(SYS_DATA));
365 gpsSysSpecificData = &gsSysSpecificData;
366 OSMemSet(gpsSysSpecificData, 0, sizeof(SYS_SPECIFIC_DATA));
368 gpsSysData->pvSysSpecificData = gpsSysSpecificData;
370 eError = OSInitEnvData(&gpsSysData->pvEnvSpecificData);
371 if (eError != PVRSRV_OK)
372 {
373 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to setup env structure"));
374 (IMG_VOID)SysDeinitialise(gpsSysData);
375 gpsSysData = IMG_NULL;
376 return eError;
377 }
378 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_ENVDATA);
380 gpsSysData->ui32NumDevices = SYS_DEVICE_COUNT;
382 /* init device ID's */
383 for(i=0; i<SYS_DEVICE_COUNT; i++)
384 {
385 gpsSysData->sDeviceID[i].uiID = i;
386 gpsSysData->sDeviceID[i].bInUse = IMG_FALSE;
387 }
389 gpsSysData->psDeviceNodeList = IMG_NULL;
390 gpsSysData->psQueueList = IMG_NULL;
392 eError = SysInitialiseCommon(gpsSysData);
393 if (eError != PVRSRV_OK)
394 {
395 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed in SysInitialiseCommon"));
396 (IMG_VOID)SysDeinitialise(gpsSysData);
397 gpsSysData = IMG_NULL;
398 return eError;
399 }
401 #if !defined(SGX_DYNAMIC_TIMING_INFO)
402 /* Set up timing information*/
403 psTimingInfo = &gsSGXDeviceMap.sTimingInfo;
404 psTimingInfo->ui32CoreClockSpeed = SYS_SGX_CLOCK_SPEED;
405 psTimingInfo->ui32HWRecoveryFreq = SYS_SGX_HWRECOVERY_TIMEOUT_FREQ;
406 #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
407 psTimingInfo->bEnableActivePM = IMG_TRUE;
408 #else
409 psTimingInfo->bEnableActivePM = IMG_FALSE;
410 #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
411 psTimingInfo->ui32ActivePowManLatencyms = SYS_SGX_ACTIVE_POWER_LATENCY_MS;
412 psTimingInfo->ui32uKernelFreq = SYS_SGX_PDS_TIMER_FREQ;
413 #endif
415 /*
416 Setup the Source Clock Divider value
417 */
418 gpsSysSpecificData->ui32SrcClockDiv = 3;
420 /*
421 Locate the devices within the system, specifying
422 the physical addresses of each devices components
423 (regs, mem, ports etc.)
424 */
425 eError = SysLocateDevices(gpsSysData);
426 if (eError != PVRSRV_OK)
427 {
428 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to locate devices"));
429 (IMG_VOID)SysDeinitialise(gpsSysData);
430 gpsSysData = IMG_NULL;
431 return eError;
432 }
433 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_LOCATEDEV);
435 eError = SysPMRuntimeRegister(gpsSysSpecificData);
436 if (eError != PVRSRV_OK)
437 {
438 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to register with OSPM!"));
439 (IMG_VOID)SysDeinitialise(gpsSysData);
440 gpsSysData = IMG_NULL;
441 return eError;
442 }
443 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_PM_RUNTIME);
445 eError = SysDvfsInitialize(gpsSysSpecificData);
446 if (eError != PVRSRV_OK)
447 {
448 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to initialize DVFS"));
449 (IMG_VOID)SysDeinitialise(gpsSysData);
450 gpsSysData = IMG_NULL;
451 return eError;
452 }
453 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_DVFS_INIT);
455 /*
456 Register devices with the system
457 This also sets up their memory maps/heaps
458 */
459 eError = PVRSRVRegisterDevice(gpsSysData, SGXRegisterDevice,
460 DEVICE_SGX_INTERRUPT, &gui32SGXDeviceID);
461 if (eError != PVRSRV_OK)
462 {
463 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to register device!"));
464 (IMG_VOID)SysDeinitialise(gpsSysData);
465 gpsSysData = IMG_NULL;
466 return eError;
467 }
468 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_REGDEV);
470 /*
471 Once all devices are registered, specify the backing store
472 and, if required, customise the memory heap config
473 */
474 psDeviceNode = gpsSysData->psDeviceNodeList;
475 while(psDeviceNode)
476 {
477 /* perform any OEM SOC address space customisations here */
478 switch(psDeviceNode->sDevId.eDeviceType)
479 {
480 case PVRSRV_DEVICE_TYPE_SGX:
481 {
482 DEVICE_MEMORY_INFO *psDevMemoryInfo;
483 DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap;
485 /*
486 specify the backing store to use for the devices MMU PT/PDs
487 - the PT/PDs are always UMA in this system
488 */
489 psDeviceNode->psLocalDevMemArena = IMG_NULL;
491 /* useful pointers */
492 psDevMemoryInfo = &psDeviceNode->sDevMemoryInfo;
493 psDeviceMemoryHeap = psDevMemoryInfo->psDeviceMemoryHeap;
495 /* specify the backing store for all SGX heaps */
496 for(i=0; i<psDevMemoryInfo->ui32HeapCount; i++)
497 {
498 psDeviceMemoryHeap[i].ui32Attribs |= PVRSRV_BACKINGSTORE_SYSMEM_NONCONTIG;
499 }
501 gpsSGXDevNode = psDeviceNode;
502 gsSysSpecificData.psSGXDevNode = psDeviceNode;
504 break;
505 }
506 default:
507 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to find SGX device node!"));
508 return PVRSRV_ERROR_INIT_FAILURE;
509 }
511 /* advance to next device */
512 psDeviceNode = psDeviceNode->psNext;
513 }
515 eError = EnableSystemClocksWrap(gpsSysData);
516 if (eError != PVRSRV_OK)
517 {
518 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to Enable system clocks (%d)", eError));
519 (IMG_VOID)SysDeinitialise(gpsSysData);
520 gpsSysData = IMG_NULL;
521 return eError;
522 }
523 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS);
524 #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
525 eError = EnableSGXClocksWrap(gpsSysData);
526 if (eError != PVRSRV_OK)
527 {
528 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to Enable SGX clocks (%d)", eError));
529 (IMG_VOID)SysDeinitialise(gpsSysData);
530 gpsSysData = IMG_NULL;
531 return eError;
532 }
533 #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
535 eError = PVRSRVInitialiseDevice(gui32SGXDeviceID);
536 if (eError != PVRSRV_OK)
537 {
538 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to initialise device!"));
539 (IMG_VOID)SysDeinitialise(gpsSysData);
540 gpsSysData = IMG_NULL;
541 return eError;
542 }
543 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_INITDEV);
545 #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
546 /* SGX defaults to D3 power state */
547 DisableSGXClocks(gpsSysData);
548 #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
550 #if !defined(PVR_NO_OMAP_TIMER)
551 #if defined(PVR_OMAP_TIMER_BASE_IN_SYS_SPEC_DATA)
552 TimerRegPhysBase = gsSysSpecificData.sTimerRegPhysBase;
553 #else
554 TimerRegPhysBase.uiAddr = SYS_OMAP4430_GP11TIMER_REGS_SYS_PHYS_BASE;
555 #endif
556 gpsSysData->pvSOCTimerRegisterKM = IMG_NULL;
557 gpsSysData->hSOCTimerRegisterOSMemHandle = 0;
558 if (TimerRegPhysBase.uiAddr != 0)
559 {
560 OSReservePhys(TimerRegPhysBase,
561 4,
562 PVRSRV_HAP_MULTI_PROCESS|PVRSRV_HAP_UNCACHED,
563 IMG_NULL,
564 (IMG_VOID **)&gpsSysData->pvSOCTimerRegisterKM,
565 &gpsSysData->hSOCTimerRegisterOSMemHandle);
566 }
567 #endif /* !defined(PVR_NO_OMAP_TIMER) */
570 return PVRSRV_OK;
571 }
573 #if defined(CONFIG_OMAPLFB)
574 int OMAPLFBRegisterPVRDriver(void * pfnFuncTable);
575 #endif
577 /*!
578 ******************************************************************************
580 @Function SysFinalise
582 @Description Final part of initialisation at 'driver load' time
584 @Return PVRSRV_ERROR :
586 ******************************************************************************/
587 PVRSRV_ERROR SysFinalise(IMG_VOID)
588 {
589 PVRSRV_ERROR eError = PVRSRV_OK;
591 #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
592 eError = EnableSGXClocksWrap(gpsSysData);
593 if (eError != PVRSRV_OK)
594 {
595 PVR_DPF((PVR_DBG_ERROR,"SysFinalise: Failed to Enable SGX clocks (%d)", eError));
596 return eError;
597 }
598 #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
600 eError = OSInstallMISR(gpsSysData);
601 if (eError != PVRSRV_OK)
602 {
603 PVR_DPF((PVR_DBG_ERROR,"SysFinalise: Failed to install MISR"));
604 return eError;
605 }
606 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_MISR);
608 #if defined(SYS_USING_INTERRUPTS)
609 /* install a Device ISR */
610 eError = OSInstallDeviceLISR(gpsSysData, gsSGXDeviceMap.ui32IRQ, "SGX ISR", gpsSGXDevNode);
611 if (eError != PVRSRV_OK)
612 {
613 PVR_DPF((PVR_DBG_ERROR,"SysFinalise: Failed to install ISR"));
614 return eError;
615 }
616 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_LISR);
617 #if !defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
618 SysEnableSGXInterrupts(gpsSysData);
619 #endif
620 #endif /* defined(SYS_USING_INTERRUPTS) */
621 #if defined(__linux__)
622 /* Create a human readable version string for this system */
623 gpsSysData->pszVersionString = SysCreateVersionString();
624 if (!gpsSysData->pszVersionString)
625 {
626 PVR_DPF((PVR_DBG_ERROR,"SysFinalise: Failed to create a system version string"));
627 }
628 else
629 {
630 PVR_TRACE(("SysFinalise: Version string: %s", gpsSysData->pszVersionString));
631 }
632 #endif
634 #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
635 /* SGX defaults to D3 power state */
636 DisableSGXClocks(gpsSysData);
637 #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
639 #if defined(CONFIG_OMAPLFB)
640 if (OMAPLFBRegisterPVRDriver((void *)&PVRGetDisplayClassJTable) != 0)
641 {
642 PVR_DPF((PVR_DBG_ERROR,"SysFinalise: Failed to register PVR driver with omaplfb"));
643 return PVRSRV_ERROR_INIT_FAILURE;
644 }
645 #endif
647 gpsSysSpecificData->bSGXInitComplete = IMG_TRUE;
649 return eError;
650 }
653 /*!
654 ******************************************************************************
656 @Function SysDeinitialise
658 @Description De-initialises kernel services at 'driver unload' time
660 @Return PVRSRV_ERROR
662 ******************************************************************************/
663 PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData)
664 {
665 PVRSRV_ERROR eError;
667 PVR_UNREFERENCED_PARAMETER(psSysData);
669 if(gpsSysData->pvSOCTimerRegisterKM)
670 {
671 OSUnReservePhys(gpsSysData->pvSOCTimerRegisterKM,
672 4,
673 PVRSRV_HAP_MULTI_PROCESS|PVRSRV_HAP_UNCACHED,
674 gpsSysData->hSOCTimerRegisterOSMemHandle);
675 }
678 #if defined(SYS_USING_INTERRUPTS)
679 if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_LISR))
680 {
681 eError = OSUninstallDeviceLISR(gpsSysData);
682 if (eError != PVRSRV_OK)
683 {
684 PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: OSUninstallDeviceLISR failed"));
685 return eError;
686 }
687 }
688 #endif
690 if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_MISR))
691 {
692 eError = OSUninstallMISR(gpsSysData);
693 if (eError != PVRSRV_OK)
694 {
695 PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: OSUninstallMISR failed"));
696 return eError;
697 }
698 }
700 if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_INITDEV))
701 {
702 #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
703 PVR_ASSERT(SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS));
704 /* Reenable SGX clocks whilst SGX is being deinitialised. */
705 eError = EnableSGXClocksWrap(gpsSysData);
706 if (eError != PVRSRV_OK)
707 {
708 PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: EnableSGXClocks failed"));
709 return eError;
710 }
711 #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
713 /* Deinitialise SGX */
714 eError = PVRSRVDeinitialiseDevice (gui32SGXDeviceID);
715 if (eError != PVRSRV_OK)
716 {
717 PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: failed to de-init the device"));
718 return eError;
719 }
720 }
722 if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_DVFS_INIT))
723 {
724 eError = SysDvfsDeinitialize(gpsSysSpecificData);
725 if (eError != PVRSRV_OK)
726 {
727 PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: Failed to de-init DVFS"));
728 gpsSysData = IMG_NULL;
729 return eError;
730 }
731 }
733 if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_PM_RUNTIME))
734 {
735 eError = SysPMRuntimeUnregister(gpsSysSpecificData);
736 if (eError != PVRSRV_OK)
737 {
738 PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: Failed to unregister with OSPM!"));
739 gpsSysData = IMG_NULL;
740 return eError;
741 }
742 }
744 /*
745 Disable system clocks - must happen after last access to hardware.
746 */
747 if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS))
748 {
749 DisableSystemClocks(gpsSysData);
750 }
752 if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_ENVDATA))
753 {
754 eError = OSDeInitEnvData(gpsSysData->pvEnvSpecificData);
755 if (eError != PVRSRV_OK)
756 {
757 PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: failed to de-init env structure"));
758 return eError;
759 }
760 }
762 SysDeinitialiseCommon(gpsSysData);
764 #if defined(NO_HARDWARE) || defined(SGX_OCP_REGS_ENABLED)
765 if(gsSGXRegsCPUVAddr != IMG_NULL)
766 {
767 #if defined(NO_HARDWARE)
768 /* Free hardware resources. */
769 OSBaseFreeContigMemory(SYS_OMAP4430_SGX_REGS_SIZE, gsSGXRegsCPUVAddr, gsSGXDeviceMap.sRegsCpuPBase);
770 #else
771 #if defined(SGX_OCP_REGS_ENABLED)
772 OSUnMapPhysToLin(gsSGXRegsCPUVAddr,
773 gsSGXDeviceMap.ui32RegsSize,
774 PVRSRV_HAP_UNCACHED|PVRSRV_HAP_KERNEL_ONLY,
775 IMG_NULL);
777 gpvOCPRegsLinAddr = IMG_NULL;
778 #endif
779 #endif /* defined(NO_HARDWARE) */
780 gsSGXRegsCPUVAddr = IMG_NULL;
781 gsSGXDeviceMap.pvRegsCpuVBase = gsSGXRegsCPUVAddr;
782 }
783 #endif /* defined(NO_HARDWARE) || defined(SGX_OCP_REGS_ENABLED) */
786 gpsSysSpecificData->ui32SysSpecificData = 0;
787 gpsSysSpecificData->bSGXInitComplete = IMG_FALSE;
789 gpsSysData = IMG_NULL;
791 return PVRSRV_OK;
792 }
795 /*!
796 ******************************************************************************
798 @Function SysGetDeviceMemoryMap
800 @Description returns a device address map for the specified device
802 @Input eDeviceType - device type
803 @Input ppvDeviceMap - void ptr to receive device specific info.
805 @Return PVRSRV_ERROR
807 ******************************************************************************/
808 PVRSRV_ERROR SysGetDeviceMemoryMap(PVRSRV_DEVICE_TYPE eDeviceType,
809 IMG_VOID **ppvDeviceMap)
810 {
812 switch(eDeviceType)
813 {
814 case PVRSRV_DEVICE_TYPE_SGX:
815 {
816 /* just return a pointer to the structure */
817 *ppvDeviceMap = (IMG_VOID*)&gsSGXDeviceMap;
819 break;
820 }
821 default:
822 {
823 PVR_DPF((PVR_DBG_ERROR,"SysGetDeviceMemoryMap: unsupported device type"));
824 }
825 }
826 return PVRSRV_OK;
827 }
830 /*!
831 ******************************************************************************
832 @Function SysCpuPAddrToDevPAddr
834 @Description Compute a device physical address from a cpu physical
835 address. Relevant when
837 @Input cpu_paddr - cpu physical address.
838 @Input eDeviceType - device type required if DevPAddr
839 address spaces vary across devices
840 in the same system
841 @Return device physical address.
843 ******************************************************************************/
844 IMG_DEV_PHYADDR SysCpuPAddrToDevPAddr(PVRSRV_DEVICE_TYPE eDeviceType,
845 IMG_CPU_PHYADDR CpuPAddr)
846 {
847 IMG_DEV_PHYADDR DevPAddr;
849 PVR_UNREFERENCED_PARAMETER(eDeviceType);
851 /* Note: for UMA system we assume DevP == CpuP */
852 DevPAddr.uiAddr = CpuPAddr.uiAddr;
854 return DevPAddr;
855 }
857 /*!
858 ******************************************************************************
859 @Function SysSysPAddrToCpuPAddr
861 @Description Compute a cpu physical address from a system physical
862 address.
864 @Input sys_paddr - system physical address.
865 @Return cpu physical address.
867 ******************************************************************************/
868 IMG_CPU_PHYADDR SysSysPAddrToCpuPAddr (IMG_SYS_PHYADDR sys_paddr)
869 {
870 IMG_CPU_PHYADDR cpu_paddr;
872 /* This would only be an inequality if the CPU's MMU did not point to
873 sys address 0, ie. multi CPU system */
874 cpu_paddr.uiAddr = sys_paddr.uiAddr;
875 return cpu_paddr;
876 }
878 /*!
879 ******************************************************************************
880 @Function SysCpuPAddrToSysPAddr
882 @Description Compute a system physical address from a cpu physical
883 address.
885 @Input cpu_paddr - cpu physical address.
886 @Return device physical address.
888 ******************************************************************************/
889 IMG_SYS_PHYADDR SysCpuPAddrToSysPAddr (IMG_CPU_PHYADDR cpu_paddr)
890 {
891 IMG_SYS_PHYADDR sys_paddr;
893 /* This would only be an inequality if the CPU's MMU did not point to
894 sys address 0, ie. multi CPU system */
895 sys_paddr.uiAddr = cpu_paddr.uiAddr;
896 return sys_paddr;
897 }
900 /*!
901 ******************************************************************************
902 @Function SysSysPAddrToDevPAddr
904 @Description Compute a device physical address from a system physical
905 address.
907 @Input SysPAddr - system physical address.
908 @Input eDeviceType - device type required if DevPAddr
909 address spaces vary across devices
910 in the same system
912 @Return Device physical address.
914 ******************************************************************************/
915 IMG_DEV_PHYADDR SysSysPAddrToDevPAddr(PVRSRV_DEVICE_TYPE eDeviceType, IMG_SYS_PHYADDR SysPAddr)
916 {
917 IMG_DEV_PHYADDR DevPAddr;
919 PVR_UNREFERENCED_PARAMETER(eDeviceType);
921 /* Note: for UMA system we assume DevP == CpuP */
922 DevPAddr.uiAddr = SysPAddr.uiAddr;
924 return DevPAddr;
925 }
928 /*!
929 ******************************************************************************
930 @Function SysDevPAddrToSysPAddr
932 @Description Compute a device physical address from a system physical
933 address.
935 @Input DevPAddr - device physical address.
936 @Input eDeviceType - device type required if DevPAddr
937 address spaces vary across devices
938 in the same system
940 @Return System physical address.
942 ******************************************************************************/
943 IMG_SYS_PHYADDR SysDevPAddrToSysPAddr(PVRSRV_DEVICE_TYPE eDeviceType, IMG_DEV_PHYADDR DevPAddr)
944 {
945 IMG_SYS_PHYADDR SysPAddr;
947 PVR_UNREFERENCED_PARAMETER(eDeviceType);
949 /* Note: for UMA system we assume DevP == SysP */
950 SysPAddr.uiAddr = DevPAddr.uiAddr;
952 return SysPAddr;
953 }
956 /*****************************************************************************
957 @Function SysRegisterExternalDevice
959 @Description Called when a 3rd party device registers with services
961 @Input psDeviceNode - the new device node.
963 @Return IMG_VOID
964 *****************************************************************************/
965 IMG_VOID SysRegisterExternalDevice(PVRSRV_DEVICE_NODE *psDeviceNode)
966 {
967 PVR_UNREFERENCED_PARAMETER(psDeviceNode);
968 }
971 /*****************************************************************************
972 @Function SysRemoveExternalDevice
974 @Description Called when a 3rd party device unregisters from services
976 @Input psDeviceNode - the device node being removed.
978 @Return IMG_VOID
979 *****************************************************************************/
980 IMG_VOID SysRemoveExternalDevice(PVRSRV_DEVICE_NODE *psDeviceNode)
981 {
982 PVR_UNREFERENCED_PARAMETER(psDeviceNode);
983 }
985 /*!
986 ******************************************************************************
987 @Function SysGetInterruptSource
989 @Description Returns System specific information about the device(s) that
990 generated the interrupt in the system
992 @Input psSysData
993 @Input psDeviceNode
995 @Return System specific information indicating which device(s)
996 generated the interrupt
998 ******************************************************************************/
999 IMG_UINT32 SysGetInterruptSource(SYS_DATA *psSysData,
1000 PVRSRV_DEVICE_NODE *psDeviceNode)
1001 {
1002 PVR_UNREFERENCED_PARAMETER(psSysData);
1003 #if defined(NO_HARDWARE)
1004 /* no interrupts in no_hw system just return all bits */
1005 return 0xFFFFFFFF;
1006 #else
1007 /* Not a shared irq, so we know this is an interrupt for this device */
1008 return psDeviceNode->ui32SOCInterruptBit;
1009 #endif
1010 }
1013 /*!
1014 ******************************************************************************
1015 @Function SysClearInterrupts
1017 @Description Clears specified system interrupts
1019 @Input psSysData
1020 @Input ui32ClearBits
1022 @Return IMG_VOID
1024 ******************************************************************************/
1025 IMG_VOID SysClearInterrupts(SYS_DATA* psSysData, IMG_UINT32 ui32ClearBits)
1026 {
1027 PVR_UNREFERENCED_PARAMETER(ui32ClearBits);
1028 PVR_UNREFERENCED_PARAMETER(psSysData);
1029 #if !defined(NO_HARDWARE)
1030 #if defined(SGX_OCP_NO_INT_BYPASS)
1031 OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_IRQSTATUS_2, 0x1);
1032 #endif
1033 /* Flush posted writes */
1034 OSReadHWReg(((PVRSRV_SGXDEV_INFO *)gpsSGXDevNode->pvDevice)->pvRegsBaseKM, EUR_CR_EVENT_HOST_CLEAR);
1035 #endif /* defined(NO_HARDWARE) */
1036 }
1038 #if defined(SGX_OCP_NO_INT_BYPASS)
1039 /*!
1040 ******************************************************************************
1041 @Function SysEnableSGXInterrupts
1043 @Description Enables SGX interrupts
1045 @Input psSysData
1047 @Return IMG_VOID
1049 ******************************************************************************/
1050 IMG_VOID SysEnableSGXInterrupts(SYS_DATA *psSysData)
1051 {
1052 SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *)psSysData->pvSysSpecificData;
1053 if (SYS_SPECIFIC_DATA_TEST(psSysSpecData, SYS_SPECIFIC_DATA_ENABLE_LISR) && !SYS_SPECIFIC_DATA_TEST(psSysSpecData, SYS_SPECIFIC_DATA_IRQ_ENABLED))
1054 {
1055 OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_IRQSTATUS_2, 0x1);
1056 OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_IRQENABLE_SET_2, 0x1);
1057 SYS_SPECIFIC_DATA_SET(psSysSpecData, SYS_SPECIFIC_DATA_IRQ_ENABLED);
1058 }
1059 }
1061 /*!
1062 ******************************************************************************
1063 @Function SysDisableSGXInterrupts
1065 @Description Disables SGX interrupts
1067 @Input psSysData
1069 @Return IMG_VOID
1071 ******************************************************************************/
1072 IMG_VOID SysDisableSGXInterrupts(SYS_DATA *psSysData)
1073 {
1074 SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *)psSysData->pvSysSpecificData;
1076 if (SYS_SPECIFIC_DATA_TEST(psSysSpecData, SYS_SPECIFIC_DATA_IRQ_ENABLED))
1077 {
1078 OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_IRQENABLE_CLR_2, 0x1);
1079 SYS_SPECIFIC_DATA_CLEAR(psSysSpecData, SYS_SPECIFIC_DATA_IRQ_ENABLED);
1080 }
1081 }
1082 #endif /* defined(SGX_OCP_NO_INT_BYPASS) */
1084 /*!
1085 ******************************************************************************
1087 @Function SysSystemPrePowerState
1089 @Description Perform system-level processing required before a power transition
1091 @Input eNewPowerState :
1093 @Return PVRSRV_ERROR
1095 ******************************************************************************/
1096 PVRSRV_ERROR SysSystemPrePowerState(PVRSRV_SYS_POWER_STATE eNewPowerState)
1097 {
1098 PVRSRV_ERROR eError = PVRSRV_OK;
1100 if (eNewPowerState == PVRSRV_SYS_POWER_STATE_D3)
1101 {
1102 PVR_TRACE(("SysSystemPrePowerState: Entering state D3"));
1104 #if defined(SYS_USING_INTERRUPTS)
1105 if (SYS_SPECIFIC_DATA_TEST(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_LISR))
1106 {
1107 #if defined(SYS_CUSTOM_POWERLOCK_WRAP)
1108 IMG_BOOL bWrapped = WrapSystemPowerChange(&gsSysSpecificData);
1109 #endif
1110 eError = OSUninstallDeviceLISR(gpsSysData);
1111 #if defined(SYS_CUSTOM_POWERLOCK_WRAP)
1112 if (bWrapped)
1113 {
1114 UnwrapSystemPowerChange(&gsSysSpecificData);
1115 }
1116 #endif
1117 if (eError != PVRSRV_OK)
1118 {
1119 PVR_DPF((PVR_DBG_ERROR,"SysSystemPrePowerState: OSUninstallDeviceLISR failed (%d)", eError));
1120 return eError;
1121 }
1122 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_PM_UNINSTALL_LISR);
1123 SYS_SPECIFIC_DATA_CLEAR(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_LISR);
1124 }
1125 #endif
1127 if (SYS_SPECIFIC_DATA_TEST(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS))
1128 {
1129 DisableSystemClocks(gpsSysData);
1131 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_PM_DISABLE_SYSCLOCKS);
1132 SYS_SPECIFIC_DATA_CLEAR(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS);
1133 }
1134 }
1136 return eError;
1137 }
1140 /*!
1141 ******************************************************************************
1143 @Function SysSystemPostPowerState
1145 @Description Perform system-level processing required after a power transition
1147 @Input eNewPowerState :
1149 @Return PVRSRV_ERROR
1151 ******************************************************************************/
1152 PVRSRV_ERROR SysSystemPostPowerState(PVRSRV_SYS_POWER_STATE eNewPowerState)
1153 {
1154 PVRSRV_ERROR eError = PVRSRV_OK;
1156 if (eNewPowerState == PVRSRV_SYS_POWER_STATE_D0)
1157 {
1158 PVR_TRACE(("SysSystemPostPowerState: Entering state D0"));
1160 if (SYS_SPECIFIC_DATA_TEST(&gsSysSpecificData, SYS_SPECIFIC_DATA_PM_DISABLE_SYSCLOCKS))
1161 {
1162 eError = EnableSystemClocksWrap(gpsSysData);
1163 if (eError != PVRSRV_OK)
1164 {
1165 PVR_DPF((PVR_DBG_ERROR,"SysSystemPostPowerState: EnableSystemClocksWrap failed (%d)", eError));
1166 return eError;
1167 }
1168 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS);
1169 SYS_SPECIFIC_DATA_CLEAR(&gsSysSpecificData, SYS_SPECIFIC_DATA_PM_DISABLE_SYSCLOCKS);
1170 }
1172 #if defined(SYS_USING_INTERRUPTS)
1173 if (SYS_SPECIFIC_DATA_TEST(&gsSysSpecificData, SYS_SPECIFIC_DATA_PM_UNINSTALL_LISR))
1174 {
1175 #if defined(SYS_CUSTOM_POWERLOCK_WRAP)
1176 IMG_BOOL bWrapped = WrapSystemPowerChange(&gsSysSpecificData);
1177 #endif
1179 eError = OSInstallDeviceLISR(gpsSysData, gsSGXDeviceMap.ui32IRQ, "SGX ISR", gpsSGXDevNode);
1180 #if defined(SYS_CUSTOM_POWERLOCK_WRAP)
1181 if (bWrapped)
1182 {
1183 UnwrapSystemPowerChange(&gsSysSpecificData);
1184 }
1185 #endif
1186 if (eError != PVRSRV_OK)
1187 {
1188 PVR_DPF((PVR_DBG_ERROR,"SysSystemPostPowerState: OSInstallDeviceLISR failed to install ISR (%d)", eError));
1189 return eError;
1190 }
1191 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_LISR);
1192 SYS_SPECIFIC_DATA_CLEAR(&gsSysSpecificData, SYS_SPECIFIC_DATA_PM_UNINSTALL_LISR);
1193 }
1194 #endif
1195 }
1196 return eError;
1197 }
1200 /*!
1201 ******************************************************************************
1203 @Function SysDevicePrePowerState
1205 @Description Perform system level processing required before a device power
1206 transition
1208 @Input ui32DeviceIndex :
1209 @Input eNewPowerState :
1210 @Input eCurrentPowerState :
1212 @Return PVRSRV_ERROR
1214 ******************************************************************************/
1215 PVRSRV_ERROR SysDevicePrePowerState(IMG_UINT32 ui32DeviceIndex,
1216 PVRSRV_DEV_POWER_STATE eNewPowerState,
1217 PVRSRV_DEV_POWER_STATE eCurrentPowerState)
1218 {
1219 PVR_UNREFERENCED_PARAMETER(eCurrentPowerState);
1221 if (ui32DeviceIndex != gui32SGXDeviceID)
1222 {
1223 return PVRSRV_OK;
1224 }
1226 #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
1227 if (eNewPowerState == PVRSRV_DEV_POWER_STATE_OFF)
1228 {
1229 PVR_DPF((PVR_DBG_MESSAGE, "SysDevicePrePowerState: SGX Entering state D3"));
1230 DisableSGXClocks(gpsSysData);
1231 }
1232 #else /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
1233 PVR_UNREFERENCED_PARAMETER(eNewPowerState );
1234 #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
1235 return PVRSRV_OK;
1236 }
1239 /*!
1240 ******************************************************************************
1242 @Function SysDevicePostPowerState
1244 @Description Perform system level processing required after a device power
1245 transition
1247 @Input ui32DeviceIndex :
1248 @Input eNewPowerState :
1249 @Input eCurrentPowerState :
1251 @Return PVRSRV_ERROR
1253 ******************************************************************************/
1254 PVRSRV_ERROR SysDevicePostPowerState(IMG_UINT32 ui32DeviceIndex,
1255 PVRSRV_DEV_POWER_STATE eNewPowerState,
1256 PVRSRV_DEV_POWER_STATE eCurrentPowerState)
1257 {
1258 PVRSRV_ERROR eError = PVRSRV_OK;
1260 PVR_UNREFERENCED_PARAMETER(eNewPowerState);
1262 if (ui32DeviceIndex != gui32SGXDeviceID)
1263 {
1264 return eError;
1265 }
1267 #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
1268 if (eCurrentPowerState == PVRSRV_DEV_POWER_STATE_OFF)
1269 {
1270 PVR_DPF((PVR_DBG_MESSAGE, "SysDevicePostPowerState: SGX Leaving state D3"));
1271 eError = EnableSGXClocksWrap(gpsSysData);
1272 }
1273 #else /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
1274 PVR_UNREFERENCED_PARAMETER(eCurrentPowerState);
1275 #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
1277 return eError;
1278 }
1280 IMG_VOID SysLockSystemSuspend(IMG_VOID)
1281 {
1282 #if defined(CONFIG_HAS_WAKELOCK)
1283 wake_lock(&gpsSysSpecificData->wake_lock);
1284 #endif
1285 }
1287 IMG_VOID SysUnlockSystemSuspend(IMG_VOID)
1288 {
1289 #if defined(CONFIG_HAS_WAKELOCK)
1290 wake_unlock(&gpsSysSpecificData->wake_lock);
1291 #endif
1292 }
1294 /*****************************************************************************
1295 @Function SysOEMFunction
1297 @Description marshalling function for custom OEM functions
1299 @Input ui32ID - function ID
1300 @Input pvIn - in data
1301 @Output pvOut - out data
1303 @Return PVRSRV_ERROR
1304 *****************************************************************************/
1305 PVRSRV_ERROR SysOEMFunction ( IMG_UINT32 ui32ID,
1306 IMG_VOID *pvIn,
1307 IMG_UINT32 ulInSize,
1308 IMG_VOID *pvOut,
1309 IMG_UINT32 ulOutSize)
1310 {
1311 PVR_UNREFERENCED_PARAMETER(ui32ID);
1312 PVR_UNREFERENCED_PARAMETER(pvIn);
1313 PVR_UNREFERENCED_PARAMETER(ulInSize);
1314 PVR_UNREFERENCED_PARAMETER(pvOut);
1315 PVR_UNREFERENCED_PARAMETER(ulOutSize);
1317 if ((ui32ID == OEM_GET_EXT_FUNCS) &&
1318 (ulOutSize == sizeof(PVRSRV_DC_OEM_JTABLE)))
1319 {
1320 PVRSRV_DC_OEM_JTABLE *psOEMJTable = (PVRSRV_DC_OEM_JTABLE*) pvOut;
1321 psOEMJTable->pfnOEMBridgeDispatch = &PVRSRV_BridgeDispatchKM;
1322 return PVRSRV_OK;
1323 }
1325 return PVRSRV_ERROR_INVALID_PARAMS;
1326 }
1327 /******************************************************************************
1328 End of file (sysconfig.c)
1329 ******************************************************************************/