[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 #if (SGX_CORE_REV == 105)
54 #define OMAP5430_CORE_REV 0x10005
55 #elif (SGX_CORE_REV == 116)
56 #define OMAP5430_CORE_REV 0x10106
57 #endif
59 /* top level system data anchor point*/
60 SYS_DATA* gpsSysData = (SYS_DATA*)IMG_NULL;
61 SYS_DATA gsSysData;
63 static SYS_SPECIFIC_DATA gsSysSpecificData;
64 SYS_SPECIFIC_DATA *gpsSysSpecificData;
66 /* SGX structures */
67 static IMG_UINT32 gui32SGXDeviceID;
68 static SGX_DEVICE_MAP gsSGXDeviceMap;
69 static PVRSRV_DEVICE_NODE *gpsSGXDevNode;
72 #if defined(NO_HARDWARE) || defined(SGX_OCP_REGS_ENABLED)
73 static IMG_CPU_VIRTADDR gsSGXRegsCPUVAddr;
74 #endif
76 #if defined(PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO)
77 extern struct platform_device *gpsPVRLDMDev;
78 #endif
80 IMG_UINT32 PVRSRV_BridgeDispatchKM(IMG_UINT32 Ioctl,
81 IMG_BYTE *pInBuf,
82 IMG_UINT32 InBufLen,
83 IMG_BYTE *pOutBuf,
84 IMG_UINT32 OutBufLen,
85 IMG_UINT32 *pdwBytesTransferred);
87 #if defined(SGX_OCP_REGS_ENABLED)
89 static IMG_CPU_VIRTADDR gpvOCPRegsLinAddr;
91 static PVRSRV_ERROR EnableSGXClocksWrap(SYS_DATA *psSysData)
92 {
93 PVRSRV_ERROR eError = EnableSGXClocks(psSysData);
95 #if !defined(SGX_OCP_NO_INT_BYPASS)
96 if(eError == PVRSRV_OK)
97 {
98 OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_SYSCONFIG, 0x14);
99 OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_DEBUG_CONFIG, EUR_CR_OCP_DEBUG_CONFIG_THALIA_INT_BYPASS_MASK);
100 }
101 #endif
102 return eError;
103 }
105 #else /* defined(SGX_OCP_REGS_ENABLED) */
107 static INLINE PVRSRV_ERROR EnableSGXClocksWrap(SYS_DATA *psSysData)
108 {
109 return EnableSGXClocks(psSysData);
110 }
112 #endif /* defined(SGX_OCP_REGS_ENABLED) */
114 static INLINE PVRSRV_ERROR EnableSystemClocksWrap(SYS_DATA *psSysData)
115 {
116 PVRSRV_ERROR eError = EnableSystemClocks(psSysData);
118 #if !defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
119 if(eError == PVRSRV_OK)
120 {
121 /*
122 * The SGX Clocks are enabled separately if active power
123 * management is enabled.
124 */
125 eError = EnableSGXClocksWrap(psSysData);
126 if (eError != PVRSRV_OK)
127 {
128 DisableSystemClocks(psSysData);
129 }
130 }
131 #endif
133 return eError;
134 }
136 /*!
137 ******************************************************************************
139 @Function SysLocateDevices
141 @Description Specifies devices in the systems memory map
143 @Input psSysData - sys data
145 @Return PVRSRV_ERROR
147 ******************************************************************************/
148 static PVRSRV_ERROR SysLocateDevices(SYS_DATA *psSysData)
149 {
150 #if defined(NO_HARDWARE)
151 PVRSRV_ERROR eError;
152 IMG_CPU_PHYADDR sCpuPAddr;
153 #else
154 #if defined(PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO)
155 struct resource *dev_res;
156 int dev_irq;
157 #endif
158 #endif
160 PVR_UNREFERENCED_PARAMETER(psSysData);
162 /* SGX Device: */
163 gsSGXDeviceMap.ui32Flags = 0x0;
165 #if defined(NO_HARDWARE)
166 /*
167 * For no hardware, allocate some contiguous memory for the
168 * register block.
169 */
171 /* Registers */
172 gsSGXDeviceMap.ui32RegsSize = SYS_OMAP4430_SGX_REGS_SIZE;
174 eError = OSBaseAllocContigMemory(gsSGXDeviceMap.ui32RegsSize,
175 &gsSGXRegsCPUVAddr,
176 &sCpuPAddr);
177 if(eError != PVRSRV_OK)
178 {
179 return eError;
180 }
181 gsSGXDeviceMap.sRegsCpuPBase = sCpuPAddr;
182 gsSGXDeviceMap.sRegsSysPBase = SysCpuPAddrToSysPAddr(gsSGXDeviceMap.sRegsCpuPBase);
183 #if defined(__linux__)
184 /* Indicate the registers are already mapped */
185 gsSGXDeviceMap.pvRegsCpuVBase = gsSGXRegsCPUVAddr;
186 #else
187 /*
188 * FIXME: Could we just use the virtual address returned by
189 * OSBaseAllocContigMemory?
190 */
191 gsSGXDeviceMap.pvRegsCpuVBase = IMG_NULL;
192 #endif
194 OSMemSet(gsSGXRegsCPUVAddr, 0, gsSGXDeviceMap.ui32RegsSize);
196 /*
197 device interrupt IRQ
198 Note: no interrupts available on no hardware system
199 */
200 gsSGXDeviceMap.ui32IRQ = 0;
202 #else /* defined(NO_HARDWARE) */
203 #if defined(PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO)
204 /* get the resource and IRQ through platform resource API */
205 dev_res = platform_get_resource(gpsPVRLDMDev, IORESOURCE_MEM, 0);
206 if (dev_res == NULL)
207 {
208 PVR_DPF((PVR_DBG_ERROR, "%s: platform_get_resource failed", __FUNCTION__));
209 return PVRSRV_ERROR_INVALID_DEVICE;
210 }
212 dev_irq = platform_get_irq(gpsPVRLDMDev, 0);
213 if (dev_irq < 0)
214 {
215 PVR_DPF((PVR_DBG_ERROR, "%s: platform_get_irq failed (%d)", __FUNCTION__, -dev_irq));
216 return PVRSRV_ERROR_INVALID_DEVICE;
217 }
219 gsSGXDeviceMap.sRegsSysPBase.uiAddr = dev_res->start;
220 gsSGXDeviceMap.sRegsCpuPBase =
221 SysSysPAddrToCpuPAddr(gsSGXDeviceMap.sRegsSysPBase);
222 PVR_TRACE(("SGX register base: 0x%lx", (unsigned long)gsSGXDeviceMap.sRegsCpuPBase.uiAddr));
224 #if defined(SGX544) && defined(SGX_FEATURE_MP)
225 /* Workaround: Due to the change in the HWMOD, the driver is only detecting the
226 size of the first memory section. For the moment, set the size with a macro
227 until a better solution found */
228 gsSGXDeviceMap.ui32RegsSize = SYS_OMAP4430_SGX_REGS_SIZE;
229 #else
230 gsSGXDeviceMap.ui32RegsSize = (unsigned int)(dev_res->end - dev_res->start);
231 #endif
233 PVR_TRACE(("SGX register size: %d",gsSGXDeviceMap.ui32RegsSize));
235 gsSGXDeviceMap.ui32IRQ = dev_irq;
236 PVR_TRACE(("SGX IRQ: %d", gsSGXDeviceMap.ui32IRQ));
237 #else /* defined(PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO) */
238 gsSGXDeviceMap.sRegsSysPBase.uiAddr = SYS_OMAP4430_SGX_REGS_SYS_PHYS_BASE;
239 gsSGXDeviceMap.sRegsCpuPBase = SysSysPAddrToCpuPAddr(gsSGXDeviceMap.sRegsSysPBase);
240 gsSGXDeviceMap.ui32RegsSize = SYS_OMAP4430_SGX_REGS_SIZE;
242 gsSGXDeviceMap.ui32IRQ = SYS_OMAP4430_SGX_IRQ;
244 #endif /* defined(PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO) */
245 #if defined(SGX_OCP_REGS_ENABLED)
246 gsSGXRegsCPUVAddr = OSMapPhysToLin(gsSGXDeviceMap.sRegsCpuPBase,
247 gsSGXDeviceMap.ui32RegsSize,
248 PVRSRV_HAP_UNCACHED|PVRSRV_HAP_KERNEL_ONLY,
249 IMG_NULL);
251 if (gsSGXRegsCPUVAddr == IMG_NULL)
252 {
253 PVR_DPF((PVR_DBG_ERROR,"SysLocateDevices: Failed to map SGX registers"));
254 return PVRSRV_ERROR_BAD_MAPPING;
255 }
257 /* Indicate the registers are already mapped */
258 gsSGXDeviceMap.pvRegsCpuVBase = gsSGXRegsCPUVAddr;
259 gpvOCPRegsLinAddr = gsSGXRegsCPUVAddr;
260 #endif
261 #endif /* defined(NO_HARDWARE) */
263 #if defined(PDUMP)
264 {
265 /* initialise memory region name for pdumping */
266 static IMG_CHAR pszPDumpDevName[] = "SGXMEM";
267 gsSGXDeviceMap.pszPDumpDevName = pszPDumpDevName;
268 }
269 #endif
271 /* add other devices here: */
274 return PVRSRV_OK;
275 }
278 /*!
279 ******************************************************************************
281 @Function SysCreateVersionString
283 @Description Read the version string
285 @Return IMG_CHAR * : Version string
287 ******************************************************************************/
288 static IMG_CHAR *SysCreateVersionString(void)
289 {
290 static IMG_CHAR aszVersionString[100];
291 SYS_DATA *psSysData;
292 IMG_UINT32 ui32SGXRevision;
293 IMG_INT32 i32Count;
294 #if !defined(NO_HARDWARE)
295 IMG_VOID *pvRegsLinAddr;
297 pvRegsLinAddr = OSMapPhysToLin(gsSGXDeviceMap.sRegsCpuPBase,
298 gsSGXDeviceMap.ui32RegsSize,
299 PVRSRV_HAP_UNCACHED|PVRSRV_HAP_KERNEL_ONLY,
300 IMG_NULL);
301 if(!pvRegsLinAddr)
302 {
303 return IMG_NULL;
304 }
306 #if defined(SGX544) && defined(SGX_FEATURE_MP)
307 ui32SGXRevision = OMAP5430_CORE_REV;
308 #else
309 ui32SGXRevision = OSReadHWReg((IMG_PVOID)((IMG_PBYTE)pvRegsLinAddr),
310 EUR_CR_CORE_REVISION);
311 #endif
313 #else
314 ui32SGXRevision = 0;
315 #endif
317 SysAcquireData(&psSysData);
319 i32Count = OSSNPrintf(aszVersionString, 100,
320 "SGX revision = %u.%u.%u",
321 (IMG_UINT)((ui32SGXRevision & EUR_CR_CORE_REVISION_MAJOR_MASK)
322 >> EUR_CR_CORE_REVISION_MAJOR_SHIFT),
323 (IMG_UINT)((ui32SGXRevision & EUR_CR_CORE_REVISION_MINOR_MASK)
324 >> EUR_CR_CORE_REVISION_MINOR_SHIFT),
325 (IMG_UINT)((ui32SGXRevision & EUR_CR_CORE_REVISION_MAINTENANCE_MASK)
326 >> EUR_CR_CORE_REVISION_MAINTENANCE_SHIFT)
327 );
329 #if !defined(NO_HARDWARE)
330 OSUnMapPhysToLin(pvRegsLinAddr,
331 SYS_OMAP4430_SGX_REGS_SIZE,
332 PVRSRV_HAP_UNCACHED|PVRSRV_HAP_KERNEL_ONLY,
333 IMG_NULL);
334 #endif
336 if(i32Count == -1)
337 {
338 return IMG_NULL;
339 }
341 return aszVersionString;
342 }
345 /*!
346 ******************************************************************************
348 @Function SysInitialise
350 @Description Initialises kernel services at 'driver load' time
352 @Return PVRSRV_ERROR :
354 ******************************************************************************/
355 PVRSRV_ERROR SysInitialise(IMG_VOID)
356 {
357 IMG_UINT32 i;
358 PVRSRV_ERROR eError;
359 PVRSRV_DEVICE_NODE *psDeviceNode;
360 #if !defined(PVR_NO_OMAP_TIMER)
361 IMG_CPU_PHYADDR TimerRegPhysBase;
362 #endif
363 #if !defined(SGX_DYNAMIC_TIMING_INFO)
364 SGX_TIMING_INFORMATION* psTimingInfo;
365 #endif
366 gpsSysData = &gsSysData;
367 OSMemSet(gpsSysData, 0, sizeof(SYS_DATA));
369 gpsSysSpecificData = &gsSysSpecificData;
370 OSMemSet(gpsSysSpecificData, 0, sizeof(SYS_SPECIFIC_DATA));
372 gpsSysData->pvSysSpecificData = gpsSysSpecificData;
374 eError = OSInitEnvData(&gpsSysData->pvEnvSpecificData);
375 if (eError != PVRSRV_OK)
376 {
377 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to setup env structure"));
378 (IMG_VOID)SysDeinitialise(gpsSysData);
379 gpsSysData = IMG_NULL;
380 return eError;
381 }
382 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_ENVDATA);
384 gpsSysData->ui32NumDevices = SYS_DEVICE_COUNT;
386 /* init device ID's */
387 for(i=0; i<SYS_DEVICE_COUNT; i++)
388 {
389 gpsSysData->sDeviceID[i].uiID = i;
390 gpsSysData->sDeviceID[i].bInUse = IMG_FALSE;
391 }
393 gpsSysData->psDeviceNodeList = IMG_NULL;
394 gpsSysData->psQueueList = IMG_NULL;
396 eError = SysInitialiseCommon(gpsSysData);
397 if (eError != PVRSRV_OK)
398 {
399 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed in SysInitialiseCommon"));
400 (IMG_VOID)SysDeinitialise(gpsSysData);
401 gpsSysData = IMG_NULL;
402 return eError;
403 }
405 #if !defined(SGX_DYNAMIC_TIMING_INFO)
406 /* Set up timing information*/
407 psTimingInfo = &gsSGXDeviceMap.sTimingInfo;
408 psTimingInfo->ui32CoreClockSpeed = SYS_SGX_CLOCK_SPEED;
409 psTimingInfo->ui32HWRecoveryFreq = SYS_SGX_HWRECOVERY_TIMEOUT_FREQ;
410 #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
411 psTimingInfo->bEnableActivePM = IMG_TRUE;
412 #else
413 psTimingInfo->bEnableActivePM = IMG_FALSE;
414 #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
415 psTimingInfo->ui32ActivePowManLatencyms = SYS_SGX_ACTIVE_POWER_LATENCY_MS;
416 psTimingInfo->ui32uKernelFreq = SYS_SGX_PDS_TIMER_FREQ;
417 #endif
419 /*
420 Setup the Source Clock Divider value
421 */
422 gpsSysSpecificData->ui32SrcClockDiv = 3;
424 /*
425 Locate the devices within the system, specifying
426 the physical addresses of each devices components
427 (regs, mem, ports etc.)
428 */
429 eError = SysLocateDevices(gpsSysData);
430 if (eError != PVRSRV_OK)
431 {
432 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to locate devices"));
433 (IMG_VOID)SysDeinitialise(gpsSysData);
434 gpsSysData = IMG_NULL;
435 return eError;
436 }
437 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_LOCATEDEV);
439 eError = SysPMRuntimeRegister(gpsSysSpecificData);
440 if (eError != PVRSRV_OK)
441 {
442 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to register with OSPM!"));
443 (IMG_VOID)SysDeinitialise(gpsSysData);
444 gpsSysData = IMG_NULL;
445 return eError;
446 }
447 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_PM_RUNTIME);
449 eError = SysDvfsInitialize(gpsSysSpecificData);
450 if (eError != PVRSRV_OK)
451 {
452 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to initialize DVFS"));
453 (IMG_VOID)SysDeinitialise(gpsSysData);
454 gpsSysData = IMG_NULL;
455 return eError;
456 }
457 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_DVFS_INIT);
459 /*
460 Register devices with the system
461 This also sets up their memory maps/heaps
462 */
463 eError = PVRSRVRegisterDevice(gpsSysData, SGXRegisterDevice,
464 DEVICE_SGX_INTERRUPT, &gui32SGXDeviceID);
465 if (eError != PVRSRV_OK)
466 {
467 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to register device!"));
468 (IMG_VOID)SysDeinitialise(gpsSysData);
469 gpsSysData = IMG_NULL;
470 return eError;
471 }
472 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_REGDEV);
474 /*
475 Once all devices are registered, specify the backing store
476 and, if required, customise the memory heap config
477 */
478 psDeviceNode = gpsSysData->psDeviceNodeList;
479 while(psDeviceNode)
480 {
481 /* perform any OEM SOC address space customisations here */
482 switch(psDeviceNode->sDevId.eDeviceType)
483 {
484 case PVRSRV_DEVICE_TYPE_SGX:
485 {
486 DEVICE_MEMORY_INFO *psDevMemoryInfo;
487 DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap;
489 /*
490 specify the backing store to use for the devices MMU PT/PDs
491 - the PT/PDs are always UMA in this system
492 */
493 psDeviceNode->psLocalDevMemArena = IMG_NULL;
495 /* useful pointers */
496 psDevMemoryInfo = &psDeviceNode->sDevMemoryInfo;
497 psDeviceMemoryHeap = psDevMemoryInfo->psDeviceMemoryHeap;
499 /* specify the backing store for all SGX heaps */
500 for(i=0; i<psDevMemoryInfo->ui32HeapCount; i++)
501 {
502 psDeviceMemoryHeap[i].ui32Attribs |= PVRSRV_BACKINGSTORE_SYSMEM_NONCONTIG;
503 }
505 gpsSGXDevNode = psDeviceNode;
506 gsSysSpecificData.psSGXDevNode = psDeviceNode;
508 break;
509 }
510 default:
511 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to find SGX device node!"));
512 return PVRSRV_ERROR_INIT_FAILURE;
513 }
515 /* advance to next device */
516 psDeviceNode = psDeviceNode->psNext;
517 }
519 eError = EnableSystemClocksWrap(gpsSysData);
520 if (eError != PVRSRV_OK)
521 {
522 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to Enable system clocks (%d)", eError));
523 (IMG_VOID)SysDeinitialise(gpsSysData);
524 gpsSysData = IMG_NULL;
525 return eError;
526 }
527 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS);
528 #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
529 eError = EnableSGXClocksWrap(gpsSysData);
530 if (eError != PVRSRV_OK)
531 {
532 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to Enable SGX clocks (%d)", eError));
533 (IMG_VOID)SysDeinitialise(gpsSysData);
534 gpsSysData = IMG_NULL;
535 return eError;
536 }
537 #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
539 eError = PVRSRVInitialiseDevice(gui32SGXDeviceID);
540 if (eError != PVRSRV_OK)
541 {
542 PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to initialise device!"));
543 (IMG_VOID)SysDeinitialise(gpsSysData);
544 gpsSysData = IMG_NULL;
545 return eError;
546 }
547 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_INITDEV);
549 #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
550 /* SGX defaults to D3 power state */
551 DisableSGXClocks(gpsSysData);
552 #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
554 #if !defined(PVR_NO_OMAP_TIMER)
555 #if defined(PVR_OMAP_TIMER_BASE_IN_SYS_SPEC_DATA)
556 TimerRegPhysBase = gsSysSpecificData.sTimerRegPhysBase;
557 #else
558 TimerRegPhysBase.uiAddr = SYS_OMAP4430_GP11TIMER_REGS_SYS_PHYS_BASE;
559 #endif
560 gpsSysData->pvSOCTimerRegisterKM = IMG_NULL;
561 gpsSysData->hSOCTimerRegisterOSMemHandle = 0;
562 if (TimerRegPhysBase.uiAddr != 0)
563 {
564 OSReservePhys(TimerRegPhysBase,
565 4,
566 PVRSRV_HAP_MULTI_PROCESS|PVRSRV_HAP_UNCACHED,
567 IMG_NULL,
568 (IMG_VOID **)&gpsSysData->pvSOCTimerRegisterKM,
569 &gpsSysData->hSOCTimerRegisterOSMemHandle);
570 }
571 #endif /* !defined(PVR_NO_OMAP_TIMER) */
574 return PVRSRV_OK;
575 }
577 #if defined(CONFIG_OMAPLFB)
578 int OMAPLFBRegisterPVRDriver(void * pfnFuncTable);
579 #endif
581 /*!
582 ******************************************************************************
584 @Function SysFinalise
586 @Description Final part of initialisation at 'driver load' time
588 @Return PVRSRV_ERROR :
590 ******************************************************************************/
591 PVRSRV_ERROR SysFinalise(IMG_VOID)
592 {
593 PVRSRV_ERROR eError = PVRSRV_OK;
595 #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
596 eError = EnableSGXClocksWrap(gpsSysData);
597 if (eError != PVRSRV_OK)
598 {
599 PVR_DPF((PVR_DBG_ERROR,"SysFinalise: Failed to Enable SGX clocks (%d)", eError));
600 return eError;
601 }
602 #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
604 eError = OSInstallMISR(gpsSysData);
605 if (eError != PVRSRV_OK)
606 {
607 PVR_DPF((PVR_DBG_ERROR,"SysFinalise: Failed to install MISR"));
608 return eError;
609 }
610 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_MISR);
612 #if defined(SYS_USING_INTERRUPTS)
613 /* install a Device ISR */
614 eError = OSInstallDeviceLISR(gpsSysData, gsSGXDeviceMap.ui32IRQ, "SGX ISR", gpsSGXDevNode);
615 if (eError != PVRSRV_OK)
616 {
617 PVR_DPF((PVR_DBG_ERROR,"SysFinalise: Failed to install ISR"));
618 return eError;
619 }
620 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_LISR);
621 #if !defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
622 SysEnableSGXInterrupts(gpsSysData);
623 #endif
624 #endif /* defined(SYS_USING_INTERRUPTS) */
625 #if defined(__linux__)
626 /* Create a human readable version string for this system */
627 gpsSysData->pszVersionString = SysCreateVersionString();
628 if (!gpsSysData->pszVersionString)
629 {
630 PVR_DPF((PVR_DBG_ERROR,"SysFinalise: Failed to create a system version string"));
631 }
632 else
633 {
634 PVR_TRACE(("SysFinalise: Version string: %s", gpsSysData->pszVersionString));
635 }
636 #endif
638 #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
639 /* SGX defaults to D3 power state */
640 DisableSGXClocks(gpsSysData);
641 #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
643 #if defined(CONFIG_OMAPLFB)
644 if (OMAPLFBRegisterPVRDriver((void *)&PVRGetDisplayClassJTable) != 0)
645 {
646 PVR_DPF((PVR_DBG_ERROR,"SysFinalise: Failed to register PVR driver with omaplfb"));
647 return PVRSRV_ERROR_INIT_FAILURE;
648 }
649 #endif
651 gpsSysSpecificData->bSGXInitComplete = IMG_TRUE;
653 return eError;
654 }
657 /*!
658 ******************************************************************************
660 @Function SysDeinitialise
662 @Description De-initialises kernel services at 'driver unload' time
664 @Return PVRSRV_ERROR
666 ******************************************************************************/
667 PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData)
668 {
669 PVRSRV_ERROR eError;
671 PVR_UNREFERENCED_PARAMETER(psSysData);
673 if(gpsSysData->pvSOCTimerRegisterKM)
674 {
675 OSUnReservePhys(gpsSysData->pvSOCTimerRegisterKM,
676 4,
677 PVRSRV_HAP_MULTI_PROCESS|PVRSRV_HAP_UNCACHED,
678 gpsSysData->hSOCTimerRegisterOSMemHandle);
679 }
682 #if defined(SYS_USING_INTERRUPTS)
683 if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_LISR))
684 {
685 eError = OSUninstallDeviceLISR(gpsSysData);
686 if (eError != PVRSRV_OK)
687 {
688 PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: OSUninstallDeviceLISR failed"));
689 return eError;
690 }
691 }
692 #endif
694 if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_MISR))
695 {
696 eError = OSUninstallMISR(gpsSysData);
697 if (eError != PVRSRV_OK)
698 {
699 PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: OSUninstallMISR failed"));
700 return eError;
701 }
702 }
704 if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_INITDEV))
705 {
706 #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
707 PVR_ASSERT(SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS));
708 /* Reenable SGX clocks whilst SGX is being deinitialised. */
709 eError = EnableSGXClocksWrap(gpsSysData);
710 if (eError != PVRSRV_OK)
711 {
712 PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: EnableSGXClocks failed"));
713 return eError;
714 }
715 #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
717 /* Deinitialise SGX */
718 eError = PVRSRVDeinitialiseDevice (gui32SGXDeviceID);
719 if (eError != PVRSRV_OK)
720 {
721 PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: failed to de-init the device"));
722 return eError;
723 }
724 }
726 if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_DVFS_INIT))
727 {
728 eError = SysDvfsDeinitialize(gpsSysSpecificData);
729 if (eError != PVRSRV_OK)
730 {
731 PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: Failed to de-init DVFS"));
732 gpsSysData = IMG_NULL;
733 return eError;
734 }
735 }
737 if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_PM_RUNTIME))
738 {
739 eError = SysPMRuntimeUnregister(gpsSysSpecificData);
740 if (eError != PVRSRV_OK)
741 {
742 PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: Failed to unregister with OSPM!"));
743 gpsSysData = IMG_NULL;
744 return eError;
745 }
746 }
748 /*
749 Disable system clocks - must happen after last access to hardware.
750 */
751 if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS))
752 {
753 DisableSystemClocks(gpsSysData);
754 }
756 if (SYS_SPECIFIC_DATA_TEST(gpsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_ENVDATA))
757 {
758 eError = OSDeInitEnvData(gpsSysData->pvEnvSpecificData);
759 if (eError != PVRSRV_OK)
760 {
761 PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: failed to de-init env structure"));
762 return eError;
763 }
764 }
766 SysDeinitialiseCommon(gpsSysData);
768 #if defined(NO_HARDWARE) || defined(SGX_OCP_REGS_ENABLED)
769 if(gsSGXRegsCPUVAddr != IMG_NULL)
770 {
771 #if defined(NO_HARDWARE)
772 /* Free hardware resources. */
773 OSBaseFreeContigMemory(SYS_OMAP4430_SGX_REGS_SIZE, gsSGXRegsCPUVAddr, gsSGXDeviceMap.sRegsCpuPBase);
774 #else
775 #if defined(SGX_OCP_REGS_ENABLED)
776 OSUnMapPhysToLin(gsSGXRegsCPUVAddr,
777 gsSGXDeviceMap.ui32RegsSize,
778 PVRSRV_HAP_UNCACHED|PVRSRV_HAP_KERNEL_ONLY,
779 IMG_NULL);
781 gpvOCPRegsLinAddr = IMG_NULL;
782 #endif
783 #endif /* defined(NO_HARDWARE) */
784 gsSGXRegsCPUVAddr = IMG_NULL;
785 gsSGXDeviceMap.pvRegsCpuVBase = gsSGXRegsCPUVAddr;
786 }
787 #endif /* defined(NO_HARDWARE) || defined(SGX_OCP_REGS_ENABLED) */
790 gpsSysSpecificData->ui32SysSpecificData = 0;
791 gpsSysSpecificData->bSGXInitComplete = IMG_FALSE;
793 gpsSysData = IMG_NULL;
795 return PVRSRV_OK;
796 }
799 /*!
800 ******************************************************************************
802 @Function SysGetDeviceMemoryMap
804 @Description returns a device address map for the specified device
806 @Input eDeviceType - device type
807 @Input ppvDeviceMap - void ptr to receive device specific info.
809 @Return PVRSRV_ERROR
811 ******************************************************************************/
812 PVRSRV_ERROR SysGetDeviceMemoryMap(PVRSRV_DEVICE_TYPE eDeviceType,
813 IMG_VOID **ppvDeviceMap)
814 {
816 switch(eDeviceType)
817 {
818 case PVRSRV_DEVICE_TYPE_SGX:
819 {
820 /* just return a pointer to the structure */
821 *ppvDeviceMap = (IMG_VOID*)&gsSGXDeviceMap;
823 break;
824 }
825 default:
826 {
827 PVR_DPF((PVR_DBG_ERROR,"SysGetDeviceMemoryMap: unsupported device type"));
828 }
829 }
830 return PVRSRV_OK;
831 }
834 /*!
835 ******************************************************************************
836 @Function SysCpuPAddrToDevPAddr
838 @Description Compute a device physical address from a cpu physical
839 address. Relevant when
841 @Input cpu_paddr - cpu physical address.
842 @Input eDeviceType - device type required if DevPAddr
843 address spaces vary across devices
844 in the same system
845 @Return device physical address.
847 ******************************************************************************/
848 IMG_DEV_PHYADDR SysCpuPAddrToDevPAddr(PVRSRV_DEVICE_TYPE eDeviceType,
849 IMG_CPU_PHYADDR CpuPAddr)
850 {
851 IMG_DEV_PHYADDR DevPAddr;
853 PVR_UNREFERENCED_PARAMETER(eDeviceType);
855 /* Note: for UMA system we assume DevP == CpuP */
856 DevPAddr.uiAddr = CpuPAddr.uiAddr;
858 return DevPAddr;
859 }
861 /*!
862 ******************************************************************************
863 @Function SysSysPAddrToCpuPAddr
865 @Description Compute a cpu physical address from a system physical
866 address.
868 @Input sys_paddr - system physical address.
869 @Return cpu physical address.
871 ******************************************************************************/
872 IMG_CPU_PHYADDR SysSysPAddrToCpuPAddr (IMG_SYS_PHYADDR sys_paddr)
873 {
874 IMG_CPU_PHYADDR cpu_paddr;
876 /* This would only be an inequality if the CPU's MMU did not point to
877 sys address 0, ie. multi CPU system */
878 cpu_paddr.uiAddr = sys_paddr.uiAddr;
879 return cpu_paddr;
880 }
882 /*!
883 ******************************************************************************
884 @Function SysCpuPAddrToSysPAddr
886 @Description Compute a system physical address from a cpu physical
887 address.
889 @Input cpu_paddr - cpu physical address.
890 @Return device physical address.
892 ******************************************************************************/
893 IMG_SYS_PHYADDR SysCpuPAddrToSysPAddr (IMG_CPU_PHYADDR cpu_paddr)
894 {
895 IMG_SYS_PHYADDR sys_paddr;
897 /* This would only be an inequality if the CPU's MMU did not point to
898 sys address 0, ie. multi CPU system */
899 sys_paddr.uiAddr = cpu_paddr.uiAddr;
900 return sys_paddr;
901 }
904 /*!
905 ******************************************************************************
906 @Function SysSysPAddrToDevPAddr
908 @Description Compute a device physical address from a system physical
909 address.
911 @Input SysPAddr - system physical address.
912 @Input eDeviceType - device type required if DevPAddr
913 address spaces vary across devices
914 in the same system
916 @Return Device physical address.
918 ******************************************************************************/
919 IMG_DEV_PHYADDR SysSysPAddrToDevPAddr(PVRSRV_DEVICE_TYPE eDeviceType, IMG_SYS_PHYADDR SysPAddr)
920 {
921 IMG_DEV_PHYADDR DevPAddr;
923 PVR_UNREFERENCED_PARAMETER(eDeviceType);
925 /* Note: for UMA system we assume DevP == CpuP */
926 DevPAddr.uiAddr = SysPAddr.uiAddr;
928 return DevPAddr;
929 }
932 /*!
933 ******************************************************************************
934 @Function SysDevPAddrToSysPAddr
936 @Description Compute a device physical address from a system physical
937 address.
939 @Input DevPAddr - device physical address.
940 @Input eDeviceType - device type required if DevPAddr
941 address spaces vary across devices
942 in the same system
944 @Return System physical address.
946 ******************************************************************************/
947 IMG_SYS_PHYADDR SysDevPAddrToSysPAddr(PVRSRV_DEVICE_TYPE eDeviceType, IMG_DEV_PHYADDR DevPAddr)
948 {
949 IMG_SYS_PHYADDR SysPAddr;
951 PVR_UNREFERENCED_PARAMETER(eDeviceType);
953 /* Note: for UMA system we assume DevP == SysP */
954 SysPAddr.uiAddr = DevPAddr.uiAddr;
956 return SysPAddr;
957 }
960 /*****************************************************************************
961 @Function SysRegisterExternalDevice
963 @Description Called when a 3rd party device registers with services
965 @Input psDeviceNode - the new device node.
967 @Return IMG_VOID
968 *****************************************************************************/
969 IMG_VOID SysRegisterExternalDevice(PVRSRV_DEVICE_NODE *psDeviceNode)
970 {
971 PVR_UNREFERENCED_PARAMETER(psDeviceNode);
972 }
975 /*****************************************************************************
976 @Function SysRemoveExternalDevice
978 @Description Called when a 3rd party device unregisters from services
980 @Input psDeviceNode - the device node being removed.
982 @Return IMG_VOID
983 *****************************************************************************/
984 IMG_VOID SysRemoveExternalDevice(PVRSRV_DEVICE_NODE *psDeviceNode)
985 {
986 PVR_UNREFERENCED_PARAMETER(psDeviceNode);
987 }
989 /*!
990 ******************************************************************************
991 @Function SysGetInterruptSource
993 @Description Returns System specific information about the device(s) that
994 generated the interrupt in the system
996 @Input psSysData
997 @Input psDeviceNode
999 @Return System specific information indicating which device(s)
1000 generated the interrupt
1002 ******************************************************************************/
1003 IMG_UINT32 SysGetInterruptSource(SYS_DATA *psSysData,
1004 PVRSRV_DEVICE_NODE *psDeviceNode)
1005 {
1006 PVR_UNREFERENCED_PARAMETER(psSysData);
1007 #if defined(NO_HARDWARE)
1008 /* no interrupts in no_hw system just return all bits */
1009 return 0xFFFFFFFF;
1010 #else
1011 /* Not a shared irq, so we know this is an interrupt for this device */
1012 return psDeviceNode->ui32SOCInterruptBit;
1013 #endif
1014 }
1017 /*!
1018 ******************************************************************************
1019 @Function SysClearInterrupts
1021 @Description Clears specified system interrupts
1023 @Input psSysData
1024 @Input ui32ClearBits
1026 @Return IMG_VOID
1028 ******************************************************************************/
1029 IMG_VOID SysClearInterrupts(SYS_DATA* psSysData, IMG_UINT32 ui32ClearBits)
1030 {
1031 PVR_UNREFERENCED_PARAMETER(ui32ClearBits);
1032 PVR_UNREFERENCED_PARAMETER(psSysData);
1033 #if !defined(NO_HARDWARE)
1034 #if defined(SGX_OCP_NO_INT_BYPASS)
1035 OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_IRQSTATUS_2, 0x1);
1036 #endif
1037 /* Flush posted writes */
1038 OSReadHWReg(((PVRSRV_SGXDEV_INFO *)gpsSGXDevNode->pvDevice)->pvRegsBaseKM, EUR_CR_EVENT_HOST_CLEAR);
1039 #endif /* defined(NO_HARDWARE) */
1040 }
1042 #if defined(SGX_OCP_NO_INT_BYPASS)
1043 /*!
1044 ******************************************************************************
1045 @Function SysEnableSGXInterrupts
1047 @Description Enables SGX interrupts
1049 @Input psSysData
1051 @Return IMG_VOID
1053 ******************************************************************************/
1054 IMG_VOID SysEnableSGXInterrupts(SYS_DATA *psSysData)
1055 {
1056 SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *)psSysData->pvSysSpecificData;
1057 if (SYS_SPECIFIC_DATA_TEST(psSysSpecData, SYS_SPECIFIC_DATA_ENABLE_LISR) && !SYS_SPECIFIC_DATA_TEST(psSysSpecData, SYS_SPECIFIC_DATA_IRQ_ENABLED))
1058 {
1059 OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_IRQSTATUS_2, 0x1);
1060 OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_IRQENABLE_SET_2, 0x1);
1061 SYS_SPECIFIC_DATA_SET(psSysSpecData, SYS_SPECIFIC_DATA_IRQ_ENABLED);
1062 }
1063 }
1065 /*!
1066 ******************************************************************************
1067 @Function SysDisableSGXInterrupts
1069 @Description Disables SGX interrupts
1071 @Input psSysData
1073 @Return IMG_VOID
1075 ******************************************************************************/
1076 IMG_VOID SysDisableSGXInterrupts(SYS_DATA *psSysData)
1077 {
1078 SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *)psSysData->pvSysSpecificData;
1080 if (SYS_SPECIFIC_DATA_TEST(psSysSpecData, SYS_SPECIFIC_DATA_IRQ_ENABLED))
1081 {
1082 OSWriteHWReg(gpvOCPRegsLinAddr, EUR_CR_OCP_IRQENABLE_CLR_2, 0x1);
1083 SYS_SPECIFIC_DATA_CLEAR(psSysSpecData, SYS_SPECIFIC_DATA_IRQ_ENABLED);
1084 }
1085 }
1086 #endif /* defined(SGX_OCP_NO_INT_BYPASS) */
1088 /*!
1089 ******************************************************************************
1091 @Function SysSystemPrePowerState
1093 @Description Perform system-level processing required before a power transition
1095 @Input eNewPowerState :
1097 @Return PVRSRV_ERROR
1099 ******************************************************************************/
1100 PVRSRV_ERROR SysSystemPrePowerState(PVRSRV_SYS_POWER_STATE eNewPowerState)
1101 {
1102 PVRSRV_ERROR eError = PVRSRV_OK;
1104 if (eNewPowerState == PVRSRV_SYS_POWER_STATE_D3)
1105 {
1106 PVR_TRACE(("SysSystemPrePowerState: Entering state D3"));
1108 #if defined(SYS_USING_INTERRUPTS)
1109 if (SYS_SPECIFIC_DATA_TEST(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_LISR))
1110 {
1111 #if defined(SYS_CUSTOM_POWERLOCK_WRAP)
1112 IMG_BOOL bWrapped = WrapSystemPowerChange(&gsSysSpecificData);
1113 #endif
1114 eError = OSUninstallDeviceLISR(gpsSysData);
1115 #if defined(SYS_CUSTOM_POWERLOCK_WRAP)
1116 if (bWrapped)
1117 {
1118 UnwrapSystemPowerChange(&gsSysSpecificData);
1119 }
1120 #endif
1121 if (eError != PVRSRV_OK)
1122 {
1123 PVR_DPF((PVR_DBG_ERROR,"SysSystemPrePowerState: OSUninstallDeviceLISR failed (%d)", eError));
1124 return eError;
1125 }
1126 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_PM_UNINSTALL_LISR);
1127 SYS_SPECIFIC_DATA_CLEAR(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_LISR);
1128 }
1129 #endif
1131 if (SYS_SPECIFIC_DATA_TEST(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS))
1132 {
1133 DisableSystemClocks(gpsSysData);
1135 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_PM_DISABLE_SYSCLOCKS);
1136 SYS_SPECIFIC_DATA_CLEAR(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS);
1137 }
1138 }
1140 return eError;
1141 }
1144 /*!
1145 ******************************************************************************
1147 @Function SysSystemPostPowerState
1149 @Description Perform system-level processing required after a power transition
1151 @Input eNewPowerState :
1153 @Return PVRSRV_ERROR
1155 ******************************************************************************/
1156 PVRSRV_ERROR SysSystemPostPowerState(PVRSRV_SYS_POWER_STATE eNewPowerState)
1157 {
1158 PVRSRV_ERROR eError = PVRSRV_OK;
1160 if (eNewPowerState == PVRSRV_SYS_POWER_STATE_D0)
1161 {
1162 PVR_TRACE(("SysSystemPostPowerState: Entering state D0"));
1164 if (SYS_SPECIFIC_DATA_TEST(&gsSysSpecificData, SYS_SPECIFIC_DATA_PM_DISABLE_SYSCLOCKS))
1165 {
1166 eError = EnableSystemClocksWrap(gpsSysData);
1167 if (eError != PVRSRV_OK)
1168 {
1169 PVR_DPF((PVR_DBG_ERROR,"SysSystemPostPowerState: EnableSystemClocksWrap failed (%d)", eError));
1170 return eError;
1171 }
1172 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS);
1173 SYS_SPECIFIC_DATA_CLEAR(&gsSysSpecificData, SYS_SPECIFIC_DATA_PM_DISABLE_SYSCLOCKS);
1174 }
1176 #if defined(SYS_USING_INTERRUPTS)
1177 if (SYS_SPECIFIC_DATA_TEST(&gsSysSpecificData, SYS_SPECIFIC_DATA_PM_UNINSTALL_LISR))
1178 {
1179 #if defined(SYS_CUSTOM_POWERLOCK_WRAP)
1180 IMG_BOOL bWrapped = WrapSystemPowerChange(&gsSysSpecificData);
1181 #endif
1183 eError = OSInstallDeviceLISR(gpsSysData, gsSGXDeviceMap.ui32IRQ, "SGX ISR", gpsSGXDevNode);
1184 #if defined(SYS_CUSTOM_POWERLOCK_WRAP)
1185 if (bWrapped)
1186 {
1187 UnwrapSystemPowerChange(&gsSysSpecificData);
1188 }
1189 #endif
1190 if (eError != PVRSRV_OK)
1191 {
1192 PVR_DPF((PVR_DBG_ERROR,"SysSystemPostPowerState: OSInstallDeviceLISR failed to install ISR (%d)", eError));
1193 return eError;
1194 }
1195 SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_LISR);
1196 SYS_SPECIFIC_DATA_CLEAR(&gsSysSpecificData, SYS_SPECIFIC_DATA_PM_UNINSTALL_LISR);
1197 }
1198 #endif
1199 }
1200 return eError;
1201 }
1204 /*!
1205 ******************************************************************************
1207 @Function SysDevicePrePowerState
1209 @Description Perform system level processing required before a device power
1210 transition
1212 @Input ui32DeviceIndex :
1213 @Input eNewPowerState :
1214 @Input eCurrentPowerState :
1216 @Return PVRSRV_ERROR
1218 ******************************************************************************/
1219 PVRSRV_ERROR SysDevicePrePowerState(IMG_UINT32 ui32DeviceIndex,
1220 PVRSRV_DEV_POWER_STATE eNewPowerState,
1221 PVRSRV_DEV_POWER_STATE eCurrentPowerState)
1222 {
1223 PVR_UNREFERENCED_PARAMETER(eCurrentPowerState);
1225 if (ui32DeviceIndex != gui32SGXDeviceID)
1226 {
1227 return PVRSRV_OK;
1228 }
1230 #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
1231 if (eNewPowerState == PVRSRV_DEV_POWER_STATE_OFF)
1232 {
1233 PVR_DPF((PVR_DBG_MESSAGE, "SysDevicePrePowerState: SGX Entering state D3"));
1234 DisableSGXClocks(gpsSysData);
1235 }
1236 #else /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
1237 PVR_UNREFERENCED_PARAMETER(eNewPowerState );
1238 #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
1239 return PVRSRV_OK;
1240 }
1243 /*!
1244 ******************************************************************************
1246 @Function SysDevicePostPowerState
1248 @Description Perform system level processing required after a device power
1249 transition
1251 @Input ui32DeviceIndex :
1252 @Input eNewPowerState :
1253 @Input eCurrentPowerState :
1255 @Return PVRSRV_ERROR
1257 ******************************************************************************/
1258 PVRSRV_ERROR SysDevicePostPowerState(IMG_UINT32 ui32DeviceIndex,
1259 PVRSRV_DEV_POWER_STATE eNewPowerState,
1260 PVRSRV_DEV_POWER_STATE eCurrentPowerState)
1261 {
1262 PVRSRV_ERROR eError = PVRSRV_OK;
1264 PVR_UNREFERENCED_PARAMETER(eNewPowerState);
1266 if (ui32DeviceIndex != gui32SGXDeviceID)
1267 {
1268 return eError;
1269 }
1271 #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
1272 if (eCurrentPowerState == PVRSRV_DEV_POWER_STATE_OFF)
1273 {
1274 PVR_DPF((PVR_DBG_MESSAGE, "SysDevicePostPowerState: SGX Leaving state D3"));
1275 eError = EnableSGXClocksWrap(gpsSysData);
1276 }
1277 #else /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
1278 PVR_UNREFERENCED_PARAMETER(eCurrentPowerState);
1279 #endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
1281 return eError;
1282 }
1284 IMG_VOID SysLockSystemSuspend(IMG_VOID)
1285 {
1286 #if defined(CONFIG_HAS_WAKELOCK)
1287 wake_lock(&gpsSysSpecificData->wake_lock);
1288 #endif
1289 }
1291 IMG_VOID SysUnlockSystemSuspend(IMG_VOID)
1292 {
1293 #if defined(CONFIG_HAS_WAKELOCK)
1294 wake_unlock(&gpsSysSpecificData->wake_lock);
1295 #endif
1296 }
1298 /*****************************************************************************
1299 @Function SysOEMFunction
1301 @Description marshalling function for custom OEM functions
1303 @Input ui32ID - function ID
1304 @Input pvIn - in data
1305 @Output pvOut - out data
1307 @Return PVRSRV_ERROR
1308 *****************************************************************************/
1309 PVRSRV_ERROR SysOEMFunction ( IMG_UINT32 ui32ID,
1310 IMG_VOID *pvIn,
1311 IMG_UINT32 ulInSize,
1312 IMG_VOID *pvOut,
1313 IMG_UINT32 ulOutSize)
1314 {
1315 PVR_UNREFERENCED_PARAMETER(ui32ID);
1316 PVR_UNREFERENCED_PARAMETER(pvIn);
1317 PVR_UNREFERENCED_PARAMETER(ulInSize);
1318 PVR_UNREFERENCED_PARAMETER(pvOut);
1319 PVR_UNREFERENCED_PARAMETER(ulOutSize);
1321 if ((ui32ID == OEM_GET_EXT_FUNCS) &&
1322 (ulOutSize == sizeof(PVRSRV_DC_OEM_JTABLE)))
1323 {
1324 PVRSRV_DC_OEM_JTABLE *psOEMJTable = (PVRSRV_DC_OEM_JTABLE*) pvOut;
1325 psOEMJTable->pfnOEMBridgeDispatch = &PVRSRV_BridgeDispatchKM;
1326 return PVRSRV_OK;
1327 }
1329 return PVRSRV_ERROR_INVALID_PARAMS;
1330 }
1331 /******************************************************************************
1332 End of file (sysconfig.c)
1333 ******************************************************************************/