1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
|
/**********************************************************************
*
* Copyright (C) Imagination Technologies Ltd. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful but, except
* as otherwise stated in writing, without any warranty; without even the
* implied warranty of merchantability or fitness for a particular purpose.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*
* The full GNU General Public License is included in this distribution in
* the file called "COPYING".
*
* Contact Information:
* Imagination Technologies Ltd. <gpl-support@imgtec.com>
* Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
*
******************************************************************************/
#include "sgxdefs.h"
#include "services_headers.h"
#include "kerneldisplay.h"
#include "oemfuncs.h"
#include "sgxinfo.h"
#include "sgxinfokm.h"
#include <linux/platform_device.h>
#include <linux/regulator/consumer.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/cpufreq.h>
#define REAL_HARDWARE 1
#define SGX540_BASEADDR 0xf3000000
#define MAPPING_SIZE 0x10000
#define SGX540_IRQ IRQ_3D
#define SYS_SGX_CLOCK_SPEED (200000000)
#define SYS_SGX_HWRECOVERY_TIMEOUT_FREQ (100) // 10ms (100hz)
#define SYS_SGX_PDS_TIMER_FREQ (1000) // 1ms (1000hz)
#ifndef SYS_SGX_ACTIVE_POWER_LATENCY_MS
#define SYS_SGX_ACTIVE_POWER_LATENCY_MS (500)
#endif
typedef struct _SYS_SPECIFIC_DATA_TAG_
{
IMG_UINT32 ui32SysSpecificData;
} SYS_SPECIFIC_DATA;
#define SYS_SPECIFIC_DATA_ENABLE_IRQ 0x00000001UL
#define SYS_SPECIFIC_DATA_ENABLE_LISR 0x00000002UL
#define SYS_SPECIFIC_DATA_ENABLE_MISR 0x00000004UL
SYS_SPECIFIC_DATA gsSysSpecificData;
/* top level system data anchor point*/
SYS_DATA* gpsSysData = (SYS_DATA*)IMG_NULL;
SYS_DATA gsSysData;
/* SGX structures */
static IMG_UINT32 gui32SGXDeviceID;
static SGX_DEVICE_MAP gsSGXDeviceMap;
/* mimic slaveport and register block with contiguous memory */
IMG_CPU_VIRTADDR gsSGXRegsCPUVAddr;
IMG_CPU_VIRTADDR gsSGXSPCPUVAddr;
static char gszVersionString[] = "SGX540 S5PC110";
IMG_UINT32 PVRSRV_BridgeDispatchKM( IMG_UINT32 Ioctl,
IMG_BYTE *pInBuf,
IMG_UINT32 InBufLen,
IMG_BYTE *pOutBuf,
IMG_UINT32 OutBufLen,
IMG_UINT32 *pdwBytesTransferred);
#if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
/*
* We need to keep the memory bus speed up when the GPU is active.
* On the S5PV210, it is bound to the CPU freq.
* In arch/arm/mach-s5pv210/cpufreq.c, the bus speed is only lowered when the
* CPU freq is below 200MHz.
*/
#define MIN_CPU_KHZ_FREQ 200000
static struct clk *g3d_clock;
static struct regulator *g3d_pd_regulator;
static int limit_adjust_cpufreq_notifier(struct notifier_block *nb,
unsigned long event, void *data)
{
struct cpufreq_policy *policy = data;
if (event != CPUFREQ_ADJUST)
return 0;
/* This is our indicator of GPU activity */
if (regulator_is_enabled(g3d_pd_regulator))
cpufreq_verify_within_limits(policy, MIN_CPU_KHZ_FREQ,
policy->cpuinfo.max_freq);
return 0;
}
static struct notifier_block cpufreq_limit_notifier = {
.notifier_call = limit_adjust_cpufreq_notifier,
};
static PVRSRV_ERROR EnableSGXClocks(void)
{
regulator_enable(g3d_pd_regulator);
clk_enable(g3d_clock);
cpufreq_update_policy(current_thread_info()->cpu);
return PVRSRV_OK;
}
static PVRSRV_ERROR DisableSGXClocks(void)
{
clk_disable(g3d_clock);
regulator_disable(g3d_pd_regulator);
cpufreq_update_policy(current_thread_info()->cpu);
return PVRSRV_OK;
}
#endif /* defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) */
/*!
******************************************************************************
@Function SysLocateDevices
@Description specifies devices in the systems memory map
@Input psSysData - sys data
@Return PVRSRV_ERROR :
******************************************************************************/
static PVRSRV_ERROR SysLocateDevices(SYS_DATA *psSysData)
{
PVR_UNREFERENCED_PARAMETER(psSysData);
gsSGXDeviceMap.sRegsSysPBase.uiAddr = SGX540_BASEADDR;
gsSGXDeviceMap.sRegsCpuPBase = SysSysPAddrToCpuPAddr(gsSGXDeviceMap.sRegsSysPBase);
gsSGXDeviceMap.ui32RegsSize = SGX_REG_SIZE;
gsSGXDeviceMap.ui32IRQ = SGX540_IRQ;
#if defined(SGX_FEATURE_HOST_PORT)
/* HostPort: */
gsSGXDeviceMap.sHPSysPBase.uiAddr = 0;
gsSGXDeviceMap.sHPCpuPBase.uiAddr = 0;
gsSGXDeviceMap.ui32HPSize = 0;
#endif
/*
Local Device Memory Region: (not present)
Note: the device doesn't need to know about its memory
but keep info here for now
*/
gsSGXDeviceMap.sLocalMemSysPBase.uiAddr = 0;
gsSGXDeviceMap.sLocalMemDevPBase.uiAddr = 0;
gsSGXDeviceMap.sLocalMemCpuPBase.uiAddr = 0;
gsSGXDeviceMap.ui32LocalMemSize = 0;
/*
device interrupt IRQ
Note: no interrupts available on No HW system
*/
gsSGXDeviceMap.ui32IRQ = SGX540_IRQ;
#if defined(PDUMP)
{
/* initialise memory region name for pdumping */
static IMG_CHAR pszPDumpDevName[] = "SGXMEM";
gsSGXDeviceMap.pszPDumpDevName = pszPDumpDevName;
}
#endif
/* add other devices here: */
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function SysInitialise
@Description Initialises kernel services at 'driver load' time
@Return PVRSRV_ERROR :
******************************************************************************/
PVRSRV_ERROR SysInitialise(IMG_VOID)
{
IMG_UINT32 i;
PVRSRV_ERROR eError;
PVRSRV_DEVICE_NODE *psDeviceNode;
SGX_TIMING_INFORMATION* psTimingInfo;
gpsSysData = &gsSysData;
OSMemSet(gpsSysData, 0, sizeof(SYS_DATA));
#if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
{
extern struct platform_device *gpsPVRLDMDev;
g3d_pd_regulator = regulator_get(&gpsPVRLDMDev->dev, "pd");
if (IS_ERR(g3d_pd_regulator))
{
PVR_DPF((PVR_DBG_ERROR, "G3D failed to find g3d power domain"));
return PVRSRV_ERROR_INIT_FAILURE;
}
g3d_clock = clk_get(&gpsPVRLDMDev->dev, "sclk");
if (IS_ERR(g3d_clock))
{
PVR_DPF((PVR_DBG_ERROR, "G3D failed to find g3d clock source-enable"));
return PVRSRV_ERROR_INIT_FAILURE;
}
EnableSGXClocks();
}
#endif
eError = OSInitEnvData(&gpsSysData->pvEnvSpecificData);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to setup env structure"));
SysDeinitialise(gpsSysData);
gpsSysData = IMG_NULL;
return eError;
}
gpsSysData->pvSysSpecificData = (IMG_PVOID)&gsSysSpecificData;
OSMemSet(&gsSGXDeviceMap, 0, sizeof(SGX_DEVICE_MAP));
/* Set up timing information*/
psTimingInfo = &gsSGXDeviceMap.sTimingInfo;
psTimingInfo->ui32CoreClockSpeed = SYS_SGX_CLOCK_SPEED;
psTimingInfo->ui32HWRecoveryFreq = SYS_SGX_HWRECOVERY_TIMEOUT_FREQ;
psTimingInfo->ui32ActivePowManLatencyms = SYS_SGX_ACTIVE_POWER_LATENCY_MS;
psTimingInfo->ui32uKernelFreq = SYS_SGX_PDS_TIMER_FREQ;
#if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
psTimingInfo->bEnableActivePM = IMG_TRUE;
#else
psTimingInfo->bEnableActivePM = IMG_FALSE;
#endif
gpsSysData->ui32NumDevices = SYS_DEVICE_COUNT;
/* init device ID's */
for(i=0; i<SYS_DEVICE_COUNT; i++)
{
gpsSysData->sDeviceID[i].uiID = i;
gpsSysData->sDeviceID[i].bInUse = IMG_FALSE;
}
gpsSysData->psDeviceNodeList = IMG_NULL;
gpsSysData->psQueueList = IMG_NULL;
eError = SysInitialiseCommon(gpsSysData);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed in SysInitialiseCommon"));
SysDeinitialise(gpsSysData);
gpsSysData = IMG_NULL;
return eError;
}
/*
Locate the devices within the system, specifying
the physical addresses of each devices components
(regs, mem, ports etc.)
*/
eError = SysLocateDevices(gpsSysData);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to locate devices"));
SysDeinitialise(gpsSysData);
gpsSysData = IMG_NULL;
return eError;
}
/*
Register devices with the system
This also sets up their memory maps/heaps
*/
eError = PVRSRVRegisterDevice(gpsSysData, SGXRegisterDevice, 1, &gui32SGXDeviceID);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to register device!"));
SysDeinitialise(gpsSysData);
gpsSysData = IMG_NULL;
return eError;
}
/*
Once all devices are registered, specify the backing store
and, if required, customise the memory heap config
*/
psDeviceNode = gpsSysData->psDeviceNodeList;
while(psDeviceNode)
{
/* perform any OEM SOC address space customisations here */
switch(psDeviceNode->sDevId.eDeviceType)
{
case PVRSRV_DEVICE_TYPE_SGX:
{
DEVICE_MEMORY_INFO *psDevMemoryInfo;
DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap;
IMG_UINT32 ui32MemConfig;
if(gpsSysData->apsLocalDevMemArena[0] != IMG_NULL)
{
/* specify the backing store to use for the device's MMU PT/PDs */
psDeviceNode->psLocalDevMemArena = gpsSysData->apsLocalDevMemArena[0];
ui32MemConfig = PVRSRV_BACKINGSTORE_LOCALMEM_CONTIG;
}
else
{
/*
specify the backing store to use for the devices MMU PT/PDs
- the PT/PDs are always UMA in this system
*/
psDeviceNode->psLocalDevMemArena = IMG_NULL;
ui32MemConfig = PVRSRV_BACKINGSTORE_SYSMEM_NONCONTIG;
}
/* useful pointers */
psDevMemoryInfo = &psDeviceNode->sDevMemoryInfo;
psDeviceMemoryHeap = psDevMemoryInfo->psDeviceMemoryHeap;
/* specify the backing store for all SGX heaps */
for(i=0; i<psDevMemoryInfo->ui32HeapCount; i++)
{
#if defined(SGX_FEATURE_VARIABLE_MMU_PAGE_SIZE)
IMG_CHAR *pStr;
switch(psDeviceMemoryHeap[i].ui32HeapID)
{
case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_GENERAL_HEAP_ID):
{
pStr = "GeneralHeapPageSize";
break;
}
case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_GENERAL_MAPPING_HEAP_ID):
{
pStr = "GeneralMappingHeapPageSize";
break;
}
case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_TADATA_HEAP_ID):
{
pStr = "TADataHeapPageSize";
break;
}
case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_KERNEL_CODE_HEAP_ID):
{
pStr = "KernelCodeHeapPageSize";
break;
}
case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_KERNEL_DATA_HEAP_ID):
{
pStr = "KernelDataHeapPageSize";
break;
}
case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_PIXELSHADER_HEAP_ID):
{
pStr = "PixelShaderHeapPageSize";
break;
}
case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_VERTEXSHADER_HEAP_ID):
{
pStr = "VertexShaderHeapPageSize";
break;
}
case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_PDSPIXEL_CODEDATA_HEAP_ID):
{
pStr = "PDSPixelHeapPageSize";
break;
}
case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_PDSVERTEX_CODEDATA_HEAP_ID):
{
pStr = "PDSVertexHeapPageSize";
break;
}
case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_SYNCINFO_HEAP_ID):
{
pStr = "SyncInfoHeapPageSize";
break;
}
case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_3DPARAMETERS_HEAP_ID):
{
pStr = "3DParametersHeapPageSize";
break;
}
default:
{
/* not interested in other heaps */
pStr = IMG_NULL;
break;
}
}
if (pStr
&& OSReadRegistryDWORDFromString(0,
PVRSRV_REGISTRY_ROOT,
pStr,
&psDeviceMemoryHeap[i].ui32DataPageSize) == IMG_TRUE)
{
PVR_DPF((PVR_DBG_VERBOSE,"SysInitialise: set Heap %s page size to %d", pStr, psDeviceMemoryHeap[i].ui32DataPageSize));
}
#endif
/*
map the device memory allocator(s) onto
the device memory heaps as required
*/
psDeviceMemoryHeap[i].psLocalDevMemArena = gpsSysData->apsLocalDevMemArena[0];
/* set the memory config (uma | non-uma) */
psDeviceMemoryHeap[i].ui32Attribs |= ui32MemConfig;
}
break;
}
default:
PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to find SGX device node!"));
return PVRSRV_ERROR_INIT_FAILURE;
}
/* advance to next device */
psDeviceNode = psDeviceNode->psNext;
}
/*
Initialise all devices 'managed' by services:
*/
eError = PVRSRVInitialiseDevice (gui32SGXDeviceID);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to initialise device!"));
SysDeinitialise(gpsSysData);
gpsSysData = IMG_NULL;
return eError;
}
#if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
DisableSGXClocks();
#endif
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function SysFinalise
@Description Final part of initialisation
@Return PVRSRV_ERROR :
******************************************************************************/
PVRSRV_ERROR SysFinalise(IMG_VOID)
{
PVRSRV_ERROR eError;
#if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
eError = EnableSGXClocks();
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to Enable SGX clocks (%d)", eError));
(IMG_VOID)SysDeinitialise(gpsSysData);
gpsSysData = IMG_NULL;
return eError;
}
#endif
eError = OSInstallMISR(gpsSysData);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"OSInstallMISR: Failed to install MISR"));
SysDeinitialise(gpsSysData);
gpsSysData = IMG_NULL;
return eError;
}
gsSysSpecificData.ui32SysSpecificData |= SYS_SPECIFIC_DATA_ENABLE_MISR;
#if defined(SYS_USING_INTERRUPTS)
/* install a system ISR */
eError = OSInstallSystemLISR(gpsSysData, gsSGXDeviceMap.ui32IRQ);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"OSInstallSystemLISR: Failed to install ISR"));
OSUninstallMISR(gpsSysData);
SysDeinitialise(gpsSysData);
gpsSysData = IMG_NULL;
return eError;
}
gsSysSpecificData.ui32SysSpecificData |= SYS_SPECIFIC_DATA_ENABLE_LISR;
gsSysSpecificData.ui32SysSpecificData |= SYS_SPECIFIC_DATA_ENABLE_IRQ;
#endif /* defined(SYS_USING_INTERRUPTS) */
/* Create a human readable version string for this system */
gpsSysData->pszVersionString = gszVersionString;
if (!gpsSysData->pszVersionString)
{
PVR_DPF((PVR_DBG_ERROR,"SysFinalise: Failed to create a system version string"));
}
else
{
PVR_DPF((PVR_DBG_WARNING, "SysFinalise: Version string: %s", gpsSysData->pszVersionString));
}
#if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
DisableSGXClocks();
cpufreq_register_notifier(&cpufreq_limit_notifier,
CPUFREQ_POLICY_NOTIFIER);
#endif
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function SysDeinitialise
@Description De-initialises kernel services at 'driver unload' time
@Return PVRSRV_ERROR :
******************************************************************************/
PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData)
{
SYS_SPECIFIC_DATA * psSysSpecData;
PVRSRV_ERROR eError;
if (psSysData == IMG_NULL) {
PVR_DPF((PVR_DBG_ERROR, "SysDeinitialise: Called with NULL SYS_DATA pointer. Probably called before."));
return PVRSRV_OK;
}
psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData;
#if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
/* TODO: regulator and clk put. */
cpufreq_unregister_notifier(&cpufreq_limit_notifier,
CPUFREQ_POLICY_NOTIFIER);
cpufreq_update_policy(current_thread_info()->cpu);
#endif
#if defined(SYS_USING_INTERRUPTS)
if (psSysSpecData->ui32SysSpecificData & SYS_SPECIFIC_DATA_ENABLE_LISR)
{
eError = OSUninstallSystemLISR(psSysData);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: OSUninstallSystemLISR failed"));
return eError;
}
}
#endif
if (psSysSpecData->ui32SysSpecificData & SYS_SPECIFIC_DATA_ENABLE_MISR)
{
eError = OSUninstallMISR(psSysData);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: OSUninstallMISR failed"));
return eError;
}
}
/* de-initialise all services managed devices */
eError = PVRSRVDeinitialiseDevice (gui32SGXDeviceID);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: failed to de-init the device"));
return eError;
}
eError = OSDeInitEnvData(gpsSysData->pvEnvSpecificData);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"SysDeinitialise: failed to de-init env structure"));
return eError;
}
SysDeinitialiseCommon(gpsSysData);
gpsSysData = IMG_NULL;
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function SysGetDeviceMemoryMap
@Description returns a device address map for the specified device
@Input eDeviceType - device type
@Input ppvDeviceMap - void ptr to receive device specific info.
@Return PVRSRV_ERROR
******************************************************************************/
PVRSRV_ERROR SysGetDeviceMemoryMap(PVRSRV_DEVICE_TYPE eDeviceType,
IMG_VOID **ppvDeviceMap)
{
switch(eDeviceType)
{
case PVRSRV_DEVICE_TYPE_SGX:
{
/* just return a pointer to the structure */
*ppvDeviceMap = (IMG_VOID*)&gsSGXDeviceMap;
break;
}
default:
{
PVR_DPF((PVR_DBG_ERROR,"SysGetDeviceMemoryMap: unsupported device type"));
}
}
return PVRSRV_OK;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: SysCpuPAddrToDevPAddr
PURPOSE: Compute a device physical address from a cpu physical
address. Relevant when
PARAMETERS: In: cpu_paddr - cpu physical address.
In: eDeviceType - device type required if DevPAddr
address spaces vary across devices
in the same system
RETURNS: device physical address.
</function>
------------------------------------------------------------------------------*/
IMG_DEV_PHYADDR SysCpuPAddrToDevPAddr (PVRSRV_DEVICE_TYPE eDeviceType,
IMG_CPU_PHYADDR CpuPAddr)
{
IMG_DEV_PHYADDR DevPAddr;
PVR_UNREFERENCED_PARAMETER(eDeviceType);
/* Note: for no HW UMA system we assume DevP == CpuP */
DevPAddr.uiAddr = CpuPAddr.uiAddr;
return DevPAddr;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: SysSysPAddrToCpuPAddr
PURPOSE: Compute a cpu physical address from a system physical
address.
PARAMETERS: In: sys_paddr - system physical address.
RETURNS: cpu physical address.
</function>
------------------------------------------------------------------------------*/
IMG_CPU_PHYADDR SysSysPAddrToCpuPAddr (IMG_SYS_PHYADDR sys_paddr)
{
IMG_CPU_PHYADDR cpu_paddr;
/* This would only be an inequality if the CPU's MMU did not point to sys address 0,
ie. multi CPU system */
cpu_paddr.uiAddr = sys_paddr.uiAddr;
return cpu_paddr;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: SysCpuPAddrToSysPAddr
PURPOSE: Compute a system physical address from a cpu physical
address.
PARAMETERS: In: cpu_paddr - cpu physical address.
RETURNS: device physical address.
</function>
------------------------------------------------------------------------------*/
IMG_SYS_PHYADDR SysCpuPAddrToSysPAddr (IMG_CPU_PHYADDR cpu_paddr)
{
IMG_SYS_PHYADDR sys_paddr;
/* This would only be an inequality if the CPU's MMU did not point to sys address 0,
ie. multi CPU system */
sys_paddr.uiAddr = cpu_paddr.uiAddr;
return sys_paddr;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: SysSysPAddrToDevPAddr
PURPOSE: Compute a device physical address from a system physical
address.
PARAMETERS: In: SysPAddr - system physical address.
In: eDeviceType - device type required if DevPAddr
address spaces vary across devices
in the same system
RETURNS: Device physical address.
</function>
-----------------------------------------------------------------------------*/
IMG_DEV_PHYADDR SysSysPAddrToDevPAddr (PVRSRV_DEVICE_TYPE eDeviceType, IMG_SYS_PHYADDR SysPAddr)
{
IMG_DEV_PHYADDR DevPAddr;
PVR_UNREFERENCED_PARAMETER(eDeviceType);
/* Note: for no HW UMA system we assume DevP == CpuP */
DevPAddr.uiAddr = SysPAddr.uiAddr;
return DevPAddr;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: SysDevPAddrToSysPAddr
PURPOSE: Compute a device physical address from a system physical
address.
PARAMETERS: In: DevPAddr - device physical address.
In: eDeviceType - device type required if DevPAddr
address spaces vary across devices
in the same system
RETURNS: System physical address.
</function>
-----------------------------------------------------------------------------*/
IMG_SYS_PHYADDR SysDevPAddrToSysPAddr (PVRSRV_DEVICE_TYPE eDeviceType, IMG_DEV_PHYADDR DevPAddr)
{
IMG_SYS_PHYADDR SysPAddr;
PVR_UNREFERENCED_PARAMETER(eDeviceType);
/* Note: for no HW UMA system we assume DevP == SysP */
SysPAddr.uiAddr = DevPAddr.uiAddr;
return SysPAddr;
}
/*****************************************************************************
FUNCTION : SysRegisterExternalDevice
PURPOSE : Called when a 3rd party device registers with services
PARAMETERS: In: psDeviceNode - the new device node.
RETURNS : IMG_VOID
*****************************************************************************/
IMG_VOID SysRegisterExternalDevice(PVRSRV_DEVICE_NODE *psDeviceNode)
{
PVR_UNREFERENCED_PARAMETER(psDeviceNode);
}
/*****************************************************************************
FUNCTION : SysRemoveExternalDevice
PURPOSE : Called when a 3rd party device unregisters from services
PARAMETERS: In: psDeviceNode - the device node being removed.
RETURNS : IMG_VOID
*****************************************************************************/
IMG_VOID SysRemoveExternalDevice(PVRSRV_DEVICE_NODE *psDeviceNode)
{
PVR_UNREFERENCED_PARAMETER(psDeviceNode);
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: SysGetInterruptSource
PURPOSE: Returns System specific information about the device(s) that
generated the interrupt in the system
PARAMETERS: In: psSysData
In: psDeviceNode
RETURNS: System specific information indicating which device(s)
generated the interrupt
</function>
-----------------------------------------------------------------------------*/
IMG_UINT32 SysGetInterruptSource(SYS_DATA* psSysData,
PVRSRV_DEVICE_NODE *psDeviceNode)
{
PVR_UNREFERENCED_PARAMETER(psSysData);
PVR_UNREFERENCED_PARAMETER(psDeviceNode);
#if defined(NO_HARDWARE)
/* no interrupts in no_hw system just return all bits */
return 0xFFFFFFFF;
#else
return 0x1;
#endif
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: SysGetInterruptSource
PURPOSE: Clears specified system interrupts
PARAMETERS: psSysData
ui32ClearBits
RETURNS: IMG_VOID
</function>
-----------------------------------------------------------------------------*/
IMG_VOID SysClearInterrupts(SYS_DATA* psSysData, IMG_UINT32 ui32ClearBits)
{
PVR_UNREFERENCED_PARAMETER(psSysData);
PVR_UNREFERENCED_PARAMETER(ui32ClearBits);
/* no interrupts in no_hw system, nothing to do */
}
/*!
******************************************************************************
@Function SysSystemPrePowerState
@Description Perform system-level processing required before a power transition
@Input eNewPowerState :
@Return PVRSRV_ERROR :
******************************************************************************/
PVRSRV_ERROR SysSystemPrePowerState(PVRSRV_SYS_POWER_STATE eNewPowerState)
{
PVR_UNREFERENCED_PARAMETER(eNewPowerState);
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function SysSystemPostPowerState
@Description Perform system-level processing required after a power transition
@Input eNewPowerState :
@Return PVRSRV_ERROR :
******************************************************************************/
PVRSRV_ERROR SysSystemPostPowerState(PVRSRV_SYS_POWER_STATE eNewPowerState)
{
PVR_UNREFERENCED_PARAMETER(eNewPowerState);
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function SysDevicePrePowerState
@Description Perform system-level processing required before a device power
transition
@Input ui32DeviceIndex :
@Input eNewPowerState :
@Input eCurrentPowerState :
@Return PVRSRV_ERROR
******************************************************************************/
PVRSRV_ERROR SysDevicePrePowerState(IMG_UINT32 ui32DeviceIndex,
PVRSRV_DEV_POWER_STATE eNewPowerState,
PVRSRV_DEV_POWER_STATE eCurrentPowerState)
{
PVR_UNREFERENCED_PARAMETER(eCurrentPowerState);
if (ui32DeviceIndex != gui32SGXDeviceID)
{
return PVRSRV_OK;
}
#if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
if (eNewPowerState == PVRSRV_DEV_POWER_STATE_OFF)
{
PVRSRVSetDCState(DC_STATE_FLUSH_COMMANDS);
PVR_DPF((PVR_DBG_MESSAGE, "SysDevicePrePowerState: SGX Entering state D3"));
DisableSGXClocks();
PVRSRVSetDCState(DC_STATE_NO_FLUSH_COMMANDS);
}
#else
PVR_UNREFERENCED_PARAMETER(eNewPowerState);
#endif
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function SysDevicePostPowerState
@Description Perform system-level processing required after a device power
transition
@Input ui32DeviceIndex :
@Input eNewPowerState :
@Input eCurrentPowerState :
@Return PVRSRV_ERROR
******************************************************************************/
PVRSRV_ERROR SysDevicePostPowerState(IMG_UINT32 ui32DeviceIndex,
PVRSRV_DEV_POWER_STATE eNewPowerState,
PVRSRV_DEV_POWER_STATE eCurrentPowerState)
{
PVRSRV_ERROR eError = PVRSRV_OK;
PVR_UNREFERENCED_PARAMETER(eCurrentPowerState);
if (ui32DeviceIndex != gui32SGXDeviceID)
{
return eError;
}
#if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
if (eNewPowerState == PVRSRV_DEV_POWER_STATE_ON)
{
PVR_DPF((PVR_DBG_MESSAGE, "SysDevicePostPowerState: SGX Leaving state D3"));
eError = EnableSGXClocks();
}
#else
PVR_UNREFERENCED_PARAMETER(eNewPowerState);
#endif
return eError;
}
/*****************************************************************************
FUNCTION : SysOEMFunction
PURPOSE : marshalling function for custom OEM functions
PARAMETERS : ui32ID - function ID
pvIn - in data
pvOut - out data
RETURNS : PVRSRV_ERROR
*****************************************************************************/
PVRSRV_ERROR SysOEMFunction(IMG_UINT32 ui32ID,
IMG_VOID *pvIn,
IMG_UINT32 ulInSize,
IMG_VOID *pvOut,
IMG_UINT32 ulOutSize)
{
PVR_UNREFERENCED_PARAMETER(ulInSize);
PVR_UNREFERENCED_PARAMETER(pvIn);
if ((ui32ID == OEM_GET_EXT_FUNCS) &&
(ulOutSize == sizeof(PVRSRV_DC_OEM_JTABLE)))
{
PVRSRV_DC_OEM_JTABLE *psOEMJTable = (PVRSRV_DC_OEM_JTABLE*)pvOut;
psOEMJTable->pfnOEMBridgeDispatch = &PVRSRV_BridgeDispatchKM;
return PVRSRV_OK;
}
return PVRSRV_ERROR_INVALID_PARAMS;
}
PVRSRV_ERROR SysPowerLockWrap(IMG_BOOL bTryLock)
{
/* FIXME: This should not be empty */
PVR_UNREFERENCED_PARAMETER(bTryLock);
return PVRSRV_OK;
}
IMG_VOID SysPowerLockUnwrap(IMG_VOID)
{
/* FIXME: This should not be empty */
}
/******************************************************************************
End of file (sysconfig.c)
******************************************************************************/
|