summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jacinto6/README.SGX2
-rw-r--r--jacinto6/sgx.tgzbin4109901 -> 4109893 bytes
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/kbuild/external_tarball.mk49
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap4430_android/Makefile194
-rw-r--r--jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap4430_android/products.mk46
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/gc_bvmapping.c147
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/gc_bvmapping.h27
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/sysfs.c90
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/sysfs.h22
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/system/omap4/oemfuncs.h80
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq.c752
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq.h97
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_activeidle.c181
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_cool.c191
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_on3demand.c324
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_onoff.c180
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_userspace.c124
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysconfig.c1333
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysconfig.h110
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysinfo.h64
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/system/omap4/syslocal.h267
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysutils.c59
-rw-r--r--jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysutils_linux.c751
23 files changed, 1 insertions, 5089 deletions
diff --git a/jacinto6/README.SGX b/jacinto6/README.SGX
index c39f59f..0d4f374 100644
--- a/jacinto6/README.SGX
+++ b/jacinto6/README.SGX
@@ -16,7 +16,7 @@ sgx.tgz a set of binaries built for SGX544.
16[DDK Version] 16[DDK Version]
17 1.12/2701748 17 1.12/2701748
18[DDK commit ID] 18[DDK commit ID]
19 2282139 omaplfb: changes for kernel 3.8 19 999e42a build: Add README for build instructions
20[Branch] 20[Branch]
21 android/1.12/2701748 21 android/1.12/2701748
22[Kernel modules built against] 22[Kernel modules built against]
diff --git a/jacinto6/sgx.tgz b/jacinto6/sgx.tgz
index 115b5f4..01d6011 100644
--- a/jacinto6/sgx.tgz
+++ b/jacinto6/sgx.tgz
Binary files differ
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/kbuild/external_tarball.mk b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/kbuild/external_tarball.mk
deleted file mode 100644
index d3aa147..0000000
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/kbuild/external_tarball.mk
+++ /dev/null
@@ -1,49 +0,0 @@
1########################################################################### ###
2#@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
3#@License Dual MIT/GPLv2
4#
5# The contents of this file are subject to the MIT license as set out below.
6#
7# Permission is hereby granted, free of charge, to any person obtaining a copy
8# of this software and associated documentation files (the "Software"), to deal
9# in the Software without restriction, including without limitation the rights
10# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11# copies of the Software, and to permit persons to whom the Software is
12# furnished to do so, subject to the following conditions:
13#
14# The above copyright notice and this permission notice shall be included in
15# all copies or substantial portions of the Software.
16#
17# Alternatively, the contents of this file may be used under the terms of
18# the GNU General Public License Version 2 ("GPL") in which case the provisions
19# of GPL are applicable instead of those above.
20#
21# If you wish to allow use of your version of this file only under the terms of
22# GPL, and not to allow others to use your version of this file under the terms
23# of the MIT license, indicate your decision by deleting the provisions above
24# and replace them with the notice and other provisions required by GPL as set
25# out in the file called "GPL-COPYING" included in this distribution. If you do
26# not delete the provisions above, a recipient may use your version of this file
27# under the terms of either the MIT license or GPL.
28#
29# This License is also included in this distribution in the file called
30# "MIT-COPYING".
31#
32# EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
33# PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
34# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
35# PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
36# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
37# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
38# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39### ###########################################################################
40
41ifneq ($(EXTERNAL_3PDD_TARBALL),)
42TAR_OPT_STRIP_COMPONENTS ?= --strip-components
43prepare_tree: $(OUT)/target/kbuild/external
44$(OUT)/target/kbuild/external: eurasiacon/external/$(EXTERNAL_3PDD_TARBALL)
45 @echo "Extracting $<.."
46 @mkdir -p $@
47 @tar $(TAR_OPT_STRIP_COMPONENTS) 1 --touch -jxf $< -C $@
48 @touch $(OUT)/target/kbuild/external
49endif
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap4430_android/Makefile b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap4430_android/Makefile
deleted file mode 100644
index 0d9ba11..0000000
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap4430_android/Makefile
+++ /dev/null
@@ -1,194 +0,0 @@
1########################################################################### ###
2#@Title Root makefile for omap4430 Android. Builds everything else.
3#@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4#@License Dual MIT/GPLv2
5#
6# The contents of this file are subject to the MIT license as set out below.
7#
8# Permission is hereby granted, free of charge, to any person obtaining a copy
9# of this software and associated documentation files (the "Software"), to deal
10# in the Software without restriction, including without limitation the rights
11# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12# copies of the Software, and to permit persons to whom the Software is
13# furnished to do so, subject to the following conditions:
14#
15# The above copyright notice and this permission notice shall be included in
16# all copies or substantial portions of the Software.
17#
18# Alternatively, the contents of this file may be used under the terms of
19# the GNU General Public License Version 2 ("GPL") in which case the provisions
20# of GPL are applicable instead of those above.
21#
22# If you wish to allow use of your version of this file only under the terms of
23# GPL, and not to allow others to use your version of this file under the terms
24# of the MIT license, indicate your decision by deleting the provisions above
25# and replace them with the notice and other provisions required by GPL as set
26# out in the file called "GPL-COPYING" included in this distribution. If you do
27# not delete the provisions above, a recipient may use your version of this file
28# under the terms of either the MIT license or GPL.
29#
30# This License is also included in this distribution in the file called
31# "MIT-COPYING".
32#
33# EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
34# PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
35# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36# PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
37# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
38# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40### ###########################################################################
41
42ifeq ($(TARGET_SGX),544sc)
43 SGXCORE := 544
44 SGX_CORE_REV := 112
45else ifeq ($(TARGET_SGX),540)
46 SGXCORE := 540
47 SGX_CORE_REV := 120
48else ifeq ($(TARGET_SGX),544)
49 SGXCORE := 544
50 SGX_CORE_REV := 105
51 HAL_VARIANT := omap5
52 SGX_FEATURE_MP := 1
53 SGX_FEATURE_SYSTEM_CACHE := 1
54 SGX_FEATURE_MP_CORE_COUNT := 2
55else ifeq ($(TARGET_SGX),544es2)
56 SGXCORE := 544
57 SGX_CORE_REV := 116
58 HAL_VARIANT := omap5
59 SGX_FEATURE_MP := 1
60 SGX_FEATURE_SYSTEM_CACHE := 1
61 SGX_FEATURE_MP_CORE_COUNT := 2
62else
63 #default config
64 SGXCORE := 540
65 SGX_CORE_REV := 120
66endif
67export SGXCORE
68export SGX_CORE_REV
69
70SUPPORT_ACTIVE_POWER_MANAGEMENT := 0
71
72SGX_DYNAMIC_TIMING_INFO := 1
73
74SUPPORT_LINUX_USING_WORKQUEUES := 1
75
76DISPLAY_CONTROLLER := omaplfb
77
78PVR_SYSTEM := omap4
79HAL_VARIANT := $(PVR_SYSTEM)
80
81# We have more memory on OMAP platforms, so we can spare to make the
82# pool larger, and have higher resolutions which benefit from it.
83#
84PVR_LINUX_MEM_AREA_POOL_MAX_PAGES ?= 10800
85
86include ../common/android/paths.mk
87include ../common/android/armv7-a.mk
88include ../common/android/features.mk
89
90ifneq ($(strip $(KERNELDIR)),)
91 include ../kernel_version.mk
92 ifeq ($(call kernel-version-at-least,2,6,35),true)
93 PVR_NO_OMAP_TIMER := 1
94 endif
95 ifeq ($(call kernel-version-at-least,2,6,39),true)
96 ifeq ($(LDM_PLATFORM),1)
97 PVR_LDM_PLATFORM_PRE_REGISTERED := 1
98 PVR_LDM_PLATFORM_PRE_REGISTERED_DEV := "\"pvrsrvkm\""
99 endif
100 endif
101 ifeq ($(is_at_least_icecream_sandwich),1)
102 ifeq ($(call kernel-version-at-least,3,0),true)
103 SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED := 1
104 PVR_ANDROID_NEEDS_ACCUM_SYNC_WORKAROUND := 1
105 SYS_OMAP4_HAS_DVFS_FRAMEWORK := 1
106 endif
107 endif
108else
109 ifeq ($(is_at_least_icecream_sandwich),1)
110 $(warning "KERNELDIR is not set, so can't feature check DVFS or dsscomp.")
111 $(warning "Assuming we want DVFS and dsscomp support.")
112 SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED := 1
113 PVR_ANDROID_NEEDS_ACCUM_SYNC_WORKAROUND := 1
114 SYS_OMAP4_HAS_DVFS_FRAMEWORK := 1
115 endif
116endif
117
118ifneq ($(LDM_PLATFORM),1)
119SUPPORT_LINUX_USING_WORKQUEUES := 0
120SUPPORT_LINUX_USING_SHARED_WORKQUEUES := 1
121SUPPORT_ACTIVE_POWER_MANAGEMENT := 0
122DISPLAY_CONTROLLER := pvrlfb
123DISPLAY_CONTROLLER_COMPONENT := linux_framebuffer
124OMAP_NON_FLIP_DISPLAY := 1
125
126# The code for the omaplfb component is now hosted on a
127# different repository. No need to compile this now
128#
129# DISPLAY_CONTROLLER_COMPONENT := dc_omapfb3_linux
130
131endif
132
133ifeq ($(SUPPORT_DRI_DRM),1)
134ifeq ($(PVR_LDM_PLATFORM_PRE_REGISTERED),1)
135PVR_DRI_DRM_PLATFORM_DEV := 1
136PVR_DRI_DRM_STATIC_BUS_ID := 1
137PVR_DRI_DRM_DEV_BUS_ID := "\"platform:pvrsrvkm"\"
138else
139PVR_DRI_DRM_NOT_PCI := 1
140KERNEL_COMPONENTS += linux_drm
141endif
142EXTRA_PVRSRVKM_COMPONENTS += $(DISPLAY_CONTROLLER_COMPONENT)
143EXTRA_KBUILD_SOURCE := $(KERNELDIR)
144# FIXME: Only required for comparison with X's KM
145PVR_SECURE_DRM_AUTH_EXPORT := 1
146ifneq ($(OMAP_NON_FLIP_DISPLAY),1)
147PVR_DISPLAY_CONTROLLER_DRM_IOCTL := 1
148endif
149else
150KERNEL_COMPONENTS += $(DISPLAY_CONTROLLER_COMPONENT)
151endif
152
153SUPPORT_ANDROID_OMAP_NV12 := 1
154
155ifeq ($(is_at_least_icecream_sandwich),1)
156ifeq ($(SUPPORT_ANDROID_COMPOSER_HAL),1)
157PVR_ANDROID_USE_WINDOW_TRANSFORM_HINT := 1
158endif
159endif
160
161PVR_ANDROID_PLATFORM_HAS_LINUX_FBDEV := 1
162
163# FIXME: Remove this once vsync issues are resolved
164PVR_ANDROID_COMPOSITOR_WAIT_FOR_RENDER := 1
165
166ifeq ($(is_at_least_icecream_sandwich),1)
167-include products.mk
168endif
169
170ifeq ($(NO_HARDWARE),1)
171ifeq ($(SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED),1)
172$(info WARNING: SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED=1 is incompatible with NO_HARDWARE=1)
173$(info WARNING: Setting SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED=0 and switching to dc_nohw)
174override SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED := 0
175override DISPLAY_CONTROLLER := dcnohw
176KERNEL_COMPONENTS += dc_nohw
177endif
178endif
179
180include ../config/core.mk
181include ../common/android/extra_config.mk
182include ../common/dridrm.mk
183include ../common/opencl.mk
184include ../common/omap4.mk
185
186# Not all OMAP4 kernels have a compatible DVFS framework
187#
188$(eval $(call TunableKernelConfigC,SYS_OMAP4_HAS_DVFS_FRAMEWORK,))
189
190# If set, services allows two flips to enter the processing queue,
191# and does not add read dependencies to the set of buffers last
192# flipped to. This is necessary for DSS composition on OMAP4.
193#
194$(eval $(call TunableKernelConfigC,SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED,))
diff --git a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap4430_android/products.mk b/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap4430_android/products.mk
deleted file mode 100644
index 53073a9..0000000
--- a/jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/omap4430_android/products.mk
+++ /dev/null
@@ -1,46 +0,0 @@
1########################################################################### ###
2#@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
3#@License Dual MIT/GPLv2
4#
5# The contents of this file are subject to the MIT license as set out below.
6#
7# Permission is hereby granted, free of charge, to any person obtaining a copy
8# of this software and associated documentation files (the "Software"), to deal
9# in the Software without restriction, including without limitation the rights
10# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11# copies of the Software, and to permit persons to whom the Software is
12# furnished to do so, subject to the following conditions:
13#
14# The above copyright notice and this permission notice shall be included in
15# all copies or substantial portions of the Software.
16#
17# Alternatively, the contents of this file may be used under the terms of
18# the GNU General Public License Version 2 ("GPL") in which case the provisions
19# of GPL are applicable instead of those above.
20#
21# If you wish to allow use of your version of this file only under the terms of
22# GPL, and not to allow others to use your version of this file under the terms
23# of the MIT license, indicate your decision by deleting the provisions above
24# and replace them with the notice and other provisions required by GPL as set
25# out in the file called "GPL-COPYING" included in this distribution. If you do
26# not delete the provisions above, a recipient may use your version of this file
27# under the terms of either the MIT license or GPL.
28#
29# This License is also included in this distribution in the file called
30# "MIT-COPYING".
31#
32# EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
33# PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
34# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
35# PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
36# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
37# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
38# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39### ###########################################################################
40
41PVRSRV_USSE_EDM_STATUS_DEBUG ?= 1
42SGX_DISABLE_VISTEST_SUPPORT ?= 1
43PVRSRV_DUMP_MK_TRACE ?= 1
44PVRSRV_NEED_PVR_DPF ?= 1
45PVRSRV_NEED_PVR_TRACE ?= 1
46PVRSRV_NEED_PVR_ASSERT ?= 1
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/gc_bvmapping.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/gc_bvmapping.c
deleted file mode 100644
index 6c5d17a..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/gc_bvmapping.c
+++ /dev/null
@@ -1,147 +0,0 @@
1/*
2 * Copyright (C) 2011 Texas Instruments, Inc
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include <linux/bltsville.h>
17#include <linux/bvinternal.h>
18#include <linux/gcbv-iface.h>
19
20#include "gc_bvmapping.h"
21#include "services_headers.h"
22
23void gc_bvmap_meminfo(PVRSRV_KERNEL_MEM_INFO *psMemInfo)
24{
25 int i;
26 IMG_CPU_PHYADDR phy_addr;
27 unsigned long *page_addrs;
28 struct bvbuffdesc *buffdesc;
29 struct bvphysdesc *physdesc;
30 int num_pages;
31 struct bventry bv_entry;
32 enum bverror bv_error;
33
34 gcbv_init(&bv_entry);
35 if (!bv_entry.bv_map) {
36 psMemInfo->bvmap_handle = NULL;
37 return;
38 }
39
40 num_pages = (psMemInfo->uAllocSize +
41 PAGE_SIZE - 1) >> PAGE_SHIFT;
42
43 page_addrs = kzalloc(sizeof(*page_addrs) * num_pages, GFP_KERNEL);
44 if (!page_addrs) {
45 printk(KERN_ERR "%s: Out of memory\n", __func__);
46 return;
47 }
48
49 physdesc = kzalloc(sizeof(*physdesc), GFP_KERNEL);
50 buffdesc = kzalloc(sizeof(*buffdesc), GFP_KERNEL);
51 if (!buffdesc || !physdesc) {
52 printk(KERN_ERR "%s: Out of memory\n", __func__);
53 kfree(page_addrs);
54 kfree(physdesc);
55 kfree(buffdesc);
56 return;
57 }
58
59 for (i = 0; i < num_pages; i++) {
60 phy_addr = OSMemHandleToCpuPAddr(
61 psMemInfo->sMemBlk.hOSMemHandle, i << PAGE_SHIFT);
62 page_addrs[i] = (u32)phy_addr.uiAddr;
63 }
64
65 buffdesc->structsize = sizeof(*buffdesc);
66 buffdesc->map = NULL;
67 buffdesc->length = psMemInfo->uAllocSize;
68 buffdesc->auxtype = BVAT_PHYSDESC;
69 buffdesc->auxptr = physdesc;
70 physdesc->structsize = sizeof(*physdesc);
71 physdesc->pagesize = PAGE_SIZE;
72 physdesc->pagearray = page_addrs;
73 physdesc->pagecount = num_pages;
74
75 /*
76 * For ion allocated buffers let's verify how many planes this
77 * meminfo consist of
78 */
79 if(psMemInfo->ui32Flags & PVRSRV_MEM_ION) {
80 IMG_UINT32 num_addr_offsets = 0;
81 OSGetMemMultiPlaneInfo(psMemInfo->sMemBlk.hOSMemHandle,
82 NULL, &num_addr_offsets);
83
84 /*
85 * Account for this meminfo plane offset (relative to the base
86 * address) if necessary
87 */
88 if(num_addr_offsets > 0)
89 physdesc->pageoffset = psMemInfo->planeOffsets[0];
90
91 /*
92 * In BV there is no way to specify multiple offsets, check
93 * all planes have the same offset and report any discrepancy
94 */
95 for (i = 1; i < num_addr_offsets; i++) {
96 IMG_UINT32 plane_offset =
97 psMemInfo->planeOffsets[i] % PAGE_SIZE;
98 if (psMemInfo->planeOffsets[0] != plane_offset) {
99 printk(KERN_WARNING "%s: meminfo %p offset 0 %d"
100 " != offset %d %d, coalignment is "
101 "missing\n", __func__, psMemInfo,
102 psMemInfo->planeOffsets[0],
103 i, plane_offset);
104 }
105 }
106 }
107
108 bv_error = bv_entry.bv_map(buffdesc);
109 if (bv_error) {
110 printk(KERN_ERR "%s: Failed to map meminfo %p, bverror %d\n",
111 __func__, psMemInfo, bv_error);
112 psMemInfo->bvmap_handle = NULL;
113 } else
114 psMemInfo->bvmap_handle = buffdesc;
115
116}
117
118void gc_bvunmap_meminfo(PVRSRV_KERNEL_MEM_INFO *psMemInfo)
119{
120 struct bvbuffdesc *buffdesc;
121 struct bvphysdesc *physdesc;
122 struct bventry bv_entry;
123 enum bverror bv_error;
124
125 gcbv_init(&bv_entry);
126 if (!bv_entry.bv_map || !psMemInfo || !psMemInfo->bvmap_handle)
127 return;
128
129 buffdesc = psMemInfo->bvmap_handle;
130 physdesc = (struct bvphysdesc*) buffdesc->auxptr;
131 bv_error = bv_entry.bv_unmap(buffdesc);
132 if (bv_error) {
133 printk(KERN_ERR "%s: Failed to unmap bvhandle %p from meminfo "
134 "%p, bverror %d\n", __func__, buffdesc, psMemInfo,
135 bv_error);
136 }
137
138 kfree(physdesc->pagearray);
139 kfree(physdesc);
140 kfree(psMemInfo->bvmap_handle);
141 psMemInfo->bvmap_handle = NULL;
142}
143
144IMG_VOID *gc_meminfo_to_hndl(PVRSRV_KERNEL_MEM_INFO *psMemInfo)
145{
146 return psMemInfo->bvmap_handle;
147}
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/gc_bvmapping.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/gc_bvmapping.h
deleted file mode 100644
index 6a3a2b1..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/gc_bvmapping.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/*
2 * Copyright (C) 2011 Texas Instruments, Inc
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#ifndef GC_BVMAPPING_H
17#define GC_BVMAPPING_H
18
19#include "services_headers.h"
20
21void gc_bvunmap_meminfo(PVRSRV_KERNEL_MEM_INFO *psMemInfo);
22
23void gc_bvmap_meminfo(PVRSRV_KERNEL_MEM_INFO *psMemInfo);
24
25IMG_VOID *gc_meminfo_to_hndl(PVRSRV_KERNEL_MEM_INFO *psMemInfo);
26
27#endif
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/sysfs.c b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/sysfs.c
deleted file mode 100644
index 63066ad..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/sysfs.c
+++ /dev/null
@@ -1,90 +0,0 @@
1/*
2 * Copyright (C) 2012 Texas Instruments, Inc
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <linux/kobject.h>
18#include <linux/sysfs.h>
19#include <linux/stat.h>
20#include <asm/page.h>
21#include <linux/slab.h>
22#include "services_headers.h"
23#include "pdump_km.h"
24#include "sysfs.h"
25
26/* sysfs structures */
27struct pvrsrv_attribute {
28 struct attribute attr;
29 int sgx_version;
30 int sgx_revision;
31};
32
33static struct pvrsrv_attribute PVRSRVAttr = {
34 .attr.name = "egl.cfg",
35 .attr.mode = S_IRUGO,
36 .sgx_version = SGXCORE,
37 .sgx_revision = SGX_CORE_REV,
38};
39
40/* sysfs read function */
41static ssize_t PVRSRVEglCfgShow(struct kobject *kobj, struct attribute *attr,
42 char *buffer) {
43 struct pvrsrv_attribute *pvrsrv_attr;
44
45 pvrsrv_attr = container_of(attr, struct pvrsrv_attribute, attr);
46 return snprintf(buffer, PAGE_SIZE, "0 0 android\n0 1 POWERVR_SGX%d_%d",
47 pvrsrv_attr->sgx_version, pvrsrv_attr->sgx_revision);
48}
49
50/* sysfs write function unsupported*/
51static ssize_t PVRSRVEglCfgStore(struct kobject *kobj, struct attribute *attr,
52 const char *buffer, size_t size) {
53 PVR_DPF((PVR_DBG_ERROR, "PVRSRVEglCfgStore not implemented"));
54 return 0;
55}
56
57static struct attribute *pvrsrv_sysfs_attrs[] = {
58 &PVRSRVAttr.attr,
59 NULL
60};
61
62static const struct sysfs_ops pvrsrv_sysfs_ops = {
63 .show = PVRSRVEglCfgShow,
64 .store = PVRSRVEglCfgStore,
65};
66
67static struct kobj_type pvrsrv_ktype = {
68 .sysfs_ops = &pvrsrv_sysfs_ops,
69 .default_attrs = pvrsrv_sysfs_attrs,
70};
71
72/* create sysfs entry /sys/egl/egl.cfg to determine
73 which gfx libraries to load */
74
75int PVRSRVCreateSysfsEntry(void)
76{
77 struct kobject *egl_cfg_kobject;
78 int r;
79
80 egl_cfg_kobject = kzalloc(sizeof(*egl_cfg_kobject), GFP_KERNEL);
81 r = kobject_init_and_add(egl_cfg_kobject, &pvrsrv_ktype, NULL, "egl");
82
83 if (r) {
84 PVR_DPF((PVR_DBG_ERROR,
85 "Failed to create egl.cfg sysfs entry"));
86 return PVRSRV_ERROR_INIT_FAILURE;
87 }
88
89 return PVRSRV_OK;
90}
diff --git a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/sysfs.h b/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/sysfs.h
deleted file mode 100644
index fb8d20f..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/sysfs.h
+++ /dev/null
@@ -1,22 +0,0 @@
1/*
2 * Copyright (C) 2012 Texas Instruments, Inc
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef __SYSFS_H
18#define __SYSFS_H
19
20int PVRSRVCreateSysfsEntry(void);
21
22#endif
diff --git a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/oemfuncs.h b/jacinto6/sgx_src/eurasia_km/services4/system/omap4/oemfuncs.h
deleted file mode 100644
index 0902042..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/oemfuncs.h
+++ /dev/null
@@ -1,80 +0,0 @@
1/*************************************************************************/ /*!
2@Title SGX kernel/client driver interface structures and prototypes
3@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4@License Dual MIT/GPLv2
5
6The contents of this file are subject to the MIT license as set out below.
7
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in
16all copies or substantial portions of the Software.
17
18Alternatively, the contents of this file may be used under the terms of
19the GNU General Public License Version 2 ("GPL") in which case the provisions
20of GPL are applicable instead of those above.
21
22If you wish to allow use of your version of this file only under the terms of
23GPL, and not to allow others to use your version of this file under the terms
24of the MIT license, indicate your decision by deleting the provisions above
25and replace them with the notice and other provisions required by GPL as set
26out in the file called "GPL-COPYING" included in this distribution. If you do
27not delete the provisions above, a recipient may use your version of this file
28under the terms of either the MIT license or GPL.
29
30This License is also included in this distribution in the file called
31"MIT-COPYING".
32
33EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
34PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
35BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
37COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
38IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40*/ /**************************************************************************/
41
42#if !defined(__OEMFUNCS_H__)
43#define __OEMFUNCS_H__
44
45#if defined (__cplusplus)
46extern "C" {
47#endif
48
49/* function in/out data structures: */
50typedef IMG_UINT32 (*PFN_SRV_BRIDGEDISPATCH)( IMG_UINT32 Ioctl,
51 IMG_BYTE *pInBuf,
52 IMG_UINT32 InBufLen,
53 IMG_BYTE *pOutBuf,
54 IMG_UINT32 OutBufLen,
55 IMG_UINT32 *pdwBytesTransferred);
56/*
57 Function table for kernel 3rd party driver to kernel services
58*/
59typedef struct PVRSRV_DC_OEM_JTABLE_TAG
60{
61 PFN_SRV_BRIDGEDISPATCH pfnOEMBridgeDispatch;
62 IMG_PVOID pvDummy1;
63 IMG_PVOID pvDummy2;
64 IMG_PVOID pvDummy3;
65
66} PVRSRV_DC_OEM_JTABLE;
67
68#define OEM_GET_EXT_FUNCS (1<<1)
69
70#if defined(__cplusplus)
71}
72#endif
73
74#endif /* __OEMFUNCS_H__ */
75
76/*****************************************************************************
77 End of file (oemfuncs.h)
78*****************************************************************************/
79
80
diff --git a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq.c b/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq.c
deleted file mode 100644
index aca0c0a..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq.c
+++ /dev/null
@@ -1,752 +0,0 @@
1/*
2 * Copyright (C) 2012 Texas Instruments, Inc
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <linux/opp.h>
18#include <linux/regulator/consumer.h>
19
20#include "sgxfreq.h"
21
22static struct sgxfreq_data {
23 int freq_cnt;
24 unsigned long *freq_list;
25 unsigned long freq;
26 unsigned long freq_request;
27 unsigned long freq_limit;
28 unsigned long total_idle_time;
29 unsigned long total_active_time;
30 struct mutex freq_mutex;
31 struct list_head gov_list;
32 struct sgxfreq_governor *gov;
33 struct mutex gov_mutex;
34 struct sgxfreq_sgx_data sgx_data;
35 struct device *dev;
36#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
37 struct clk *core_clk;
38 struct clk *gpu_clk;
39 struct clk *per_clk;
40 struct clk *gpu_core_clk;
41 struct clk *gpu_hyd_clk;
42 struct regulator *gpu_reg;
43#endif
44} sfd;
45
46/* Governor init/deinit functions */
47int onoff_init(void);
48int onoff_deinit(void);
49int activeidle_init(void);
50int activeidle_deinit(void);
51int on3demand_init(void);
52int on3demand_deinit(void);
53int userspace_init(void);
54int userspace_deinit(void);
55
56
57typedef int sgxfreq_gov_init_t(void);
58sgxfreq_gov_init_t *sgxfreq_gov_init[] = {
59 onoff_init,
60 activeidle_init,
61 on3demand_init,
62 userspace_init,
63 NULL,
64};
65
66typedef int sgxfreq_gov_deinit_t(void);
67sgxfreq_gov_deinit_t *sgxfreq_gov_deinit[] = {
68 onoff_deinit,
69 activeidle_deinit,
70 on3demand_deinit,
71 userspace_deinit,
72 NULL,
73};
74
75#define SGXFREQ_DEFAULT_GOV_NAME "on3demand"
76static unsigned long _idle_curr_time;
77static unsigned long _idle_prev_time;
78static unsigned long _active_curr_time;
79static unsigned long _active_prev_time;
80
81#if (defined(CONFIG_THERMAL) || defined(CONFIG_THERMAL_FRAMEWORK))
82int cool_init(void);
83void cool_deinit(void);
84#endif
85
86/*********************** begin sysfs interface ***********************/
87
88struct kobject *sgxfreq_kobj;
89
90static ssize_t show_frequency_list(struct device *dev,
91 struct device_attribute *attr,
92 char *buf)
93{
94 int i;
95 ssize_t count = 0;
96
97 for (i = 0; i < sfd.freq_cnt; i++)
98 count += sprintf(&buf[count], "%lu ", sfd.freq_list[i]);
99 count += sprintf(&buf[count], "\n");
100
101 return count;
102}
103
104static ssize_t show_frequency_request(struct device *dev,
105 struct device_attribute *attr,
106 char *buf)
107{
108 return sprintf(buf, "%lu\n", sfd.freq_request);
109}
110
111static ssize_t show_frequency_limit(struct device *dev,
112 struct device_attribute *attr,
113 char *buf)
114{
115 return sprintf(buf, "%lu\n", sfd.freq_limit);
116}
117
118static ssize_t show_frequency(struct device *dev,
119 struct device_attribute *attr,
120 char *buf)
121{
122 return sprintf(buf, "%lu\n", sfd.freq);
123}
124
125static ssize_t show_stat(struct device *dev,
126 struct device_attribute *attr,
127 char *buf)
128{
129 return sprintf(buf, "gpu %lu %lu\n",
130 sfd.total_active_time, sfd.total_idle_time);
131}
132
133static ssize_t show_governor_list(struct device *dev,
134 struct device_attribute *attr,
135 char *buf)
136{
137 ssize_t i = 0;
138 struct sgxfreq_governor *t;
139
140 list_for_each_entry(t, &sfd.gov_list, governor_list) {
141 if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char))
142 - (SGXFREQ_NAME_LEN + 2)))
143 goto out;
144 i += scnprintf(&buf[i], SGXFREQ_NAME_LEN, "%s ", t->name);
145 }
146out:
147 i += sprintf(&buf[i], "\n");
148 return i;
149}
150
151static ssize_t show_governor(struct device *dev,
152 struct device_attribute *attr, char *buf)
153{
154 if (sfd.gov)
155 return scnprintf(buf, SGXFREQ_NAME_LEN, "%s\n", sfd.gov->name);
156
157 return sprintf(buf, "\n");
158}
159
160static ssize_t store_governor(struct device *dev,
161 struct device_attribute *attr, const char *buf,
162 size_t count)
163{
164 int ret;
165 char name[16];
166
167 ret = sscanf(buf, "%15s", name);
168 if (ret != 1)
169 return -EINVAL;
170
171 ret = sgxfreq_set_governor(name);
172 if (ret)
173 return ret;
174 else
175 return count;
176}
177
178static DEVICE_ATTR(frequency_list, 0444, show_frequency_list, NULL);
179static DEVICE_ATTR(frequency_request, 0444, show_frequency_request, NULL);
180static DEVICE_ATTR(frequency_limit, 0444, show_frequency_limit, NULL);
181static DEVICE_ATTR(frequency, 0444, show_frequency, NULL);
182static DEVICE_ATTR(governor_list, 0444, show_governor_list, NULL);
183static DEVICE_ATTR(governor, 0644, show_governor, store_governor);
184static DEVICE_ATTR(stat, 0444, show_stat, NULL);
185
186static const struct attribute *sgxfreq_attributes[] = {
187 &dev_attr_frequency_list.attr,
188 &dev_attr_frequency_request.attr,
189 &dev_attr_frequency_limit.attr,
190 &dev_attr_frequency.attr,
191 &dev_attr_governor_list.attr,
192 &dev_attr_governor.attr,
193 &dev_attr_stat.attr,
194 NULL
195};
196
197/************************ end sysfs interface ************************/
198static int set_volt_for_freq(unsigned long freq)
199{
200 struct opp *opp;
201 unsigned long volt = 0;
202 int ret;
203
204 if (sfd.gpu_reg) {
205 opp = opp_find_freq_exact(sfd.dev, freq, true);
206 if(IS_ERR(opp))
207 {
208 int r = PTR_ERR(opp);
209 pr_err("sgxfreq: Couldn't find opp matching freq: %lu. Err: %d",
210 freq, r);
211 return -1;
212 }
213
214 volt = opp_get_voltage(opp);
215 if (!volt)
216 {
217 pr_err("sgxfreq: Could find volt corresponding to freq: %lu\n",
218 freq);
219 return -1;
220 }
221
222 ret = regulator_set_voltage_tol(sfd.gpu_reg, volt , 6000);
223 if (ret) {
224 pr_err("sgxfreq: Error(%d) setting volt: %lu for freq:%lu\n",
225 ret, volt, freq);
226 return ret;
227 }
228 }
229
230 return 0;
231
232}
233
234static void __set_freq(void)
235{
236 unsigned long freq;
237 int ret = 0;
238
239 freq = min(sfd.freq_request, sfd.freq_limit);
240 if (freq != sfd.freq) {
241#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
242 if (freq > sfd.freq) {
243 /* Going up - must scale voltage before clocks */
244 if (set_volt_for_freq(freq) != 0) {
245 pr_err("sgxfreq: Error setting voltage for freq: %lu\n",
246 freq);
247 goto err1;
248 }
249 }
250
251 ret = clk_set_rate(sfd.gpu_core_clk, freq);
252 if (ret) {
253 pr_err("sgxfreq: Error(%d) setting gpu core clock rate: %lu\n",
254 ret, freq);
255 goto err2;
256 }
257
258 ret = clk_set_rate(sfd.gpu_hyd_clk, freq);
259 if (ret) {
260 pr_err("sgxfreq: Error(%d) setting gpu hyd clock rate: %lu\n",
261 ret, freq);
262 goto err3;
263 }
264
265 if (freq < sfd.freq) {
266 /* Going down - must scale voltage after clocks */
267 if(set_volt_for_freq(freq) != 0) {
268 pr_err("sgxfreq: Error setting voltage for freq: %lu\n",
269 freq);
270 goto err4;
271 }
272 }
273
274#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
275 sfd.pdata->device_scale(sfd.dev, sfd.dev, freq);
276#else
277 sfd.pdata->device_scale(sfd.dev, freq);
278#endif
279 sfd.freq = freq;
280
281 goto noerr;
282err4:
283 ret |= clk_set_rate(sfd.gpu_hyd_clk, sfd.freq);
284
285err3:
286 ret |= clk_set_rate(sfd.gpu_core_clk, sfd.freq);
287err2:
288 if(freq > sfd.freq)
289 ret |= set_volt_for_freq(sfd.freq);
290err1:
291noerr:
292 return;
293 }
294}
295
296static struct sgxfreq_governor *__find_governor(const char *name)
297{
298 struct sgxfreq_governor *t;
299
300 list_for_each_entry(t, &sfd.gov_list, governor_list)
301 if (!strnicmp(name, t->name, SGXFREQ_NAME_LEN))
302 return t;
303
304 return NULL;
305}
306
307static void __update_timing_info(bool active)
308{
309 struct timeval tv;
310 do_gettimeofday(&tv);
311 if(active)
312 {
313 if(sfd.sgx_data.active == true) {
314 _active_curr_time = __tv2msec(tv);
315 sfd.total_active_time += __delta32(
316 _active_curr_time, _active_prev_time);
317 SGXFREQ_TRACE("A->A TA:= %lums \tdA: %lums \tTI: %lums \tdI: %lums\n",
318 sfd.total_active_time,
319 __delta32(_active_curr_time, _active_prev_time),
320 sfd.total_active_time,
321 (unsigned long)0);
322 _active_prev_time = _active_curr_time;
323 } else {
324 _idle_curr_time = __tv2msec(tv);
325 _active_prev_time = _idle_curr_time;
326 sfd.total_idle_time +=
327 __delta32(_idle_curr_time, _idle_prev_time);
328 SGXFREQ_TRACE("I->A TA:= %lums \tdA: %lums \tTI: %lums \tdI: %lums\n",
329 sfd.total_active_time,
330 (unsigned long)0,
331 sfd.total_idle_time,
332 __delta32(_idle_curr_time, _idle_prev_time));
333 }
334 } else {
335 if(sfd.sgx_data.active == true)
336 {
337 _idle_prev_time = _active_curr_time = __tv2msec(tv);
338 sfd.total_active_time +=
339 __delta32(_active_curr_time, _active_prev_time);
340 SGXFREQ_TRACE("A->I TA:= %lums \tdA: %lums \tTI: %lums \tdI: %lums\n",
341 sfd.total_active_time,
342 __delta32(_active_curr_time, _active_prev_time),
343 sfd.total_active_time,
344 (unsigned long)0);
345 }
346 else
347 {
348 _idle_curr_time = __tv2msec(tv);
349 sfd.total_idle_time += __delta32(
350 _idle_curr_time, _idle_prev_time);
351 SGXFREQ_TRACE("I->I TA:= %lums \tdA: %lums \tTI: %lums \tdI: %lums\n",
352 sfd.total_active_time,
353 (unsigned long)0,
354 sfd.total_idle_time,
355 __delta32(_idle_curr_time, _idle_prev_time));
356 _idle_prev_time = _idle_curr_time;
357 }
358 }
359}
360
361int sgxfreq_init(struct device *dev)
362{
363 int i, ret;
364 unsigned long freq;
365 struct opp *opp;
366 struct timeval tv;
367
368 sfd.dev = dev;
369 if (!sfd.dev)
370 return -EINVAL;
371#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
372 sfd.pdata = (struct gpu_platform_data *)dev->platform_data;
373 if (!sfd.pdata ||
374 !sfd.pdata->opp_get_opp_count ||
375 !sfd.pdata->opp_find_freq_ceil ||
376 !sfd.pdata->device_scale)
377 return -EINVAL;
378#endif
379
380 rcu_read_lock();
381
382#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
383 sfd.freq_cnt = sfd.pdata->opp_get_opp_count(dev);
384#else
385 ret = of_init_opp_table(dev);
386 if (ret) {
387 pr_err("sgxfreq: failed to init OPP table: %d\n", ret);
388 return -EINVAL;
389 }
390
391 sfd.freq_cnt = opp_get_opp_count(dev);
392#endif
393 if (sfd.freq_cnt < 1) {
394 rcu_read_unlock();
395 return -ENODEV;
396 }
397
398 sfd.freq_list = kmalloc(sfd.freq_cnt * sizeof(unsigned long), GFP_ATOMIC);
399 if (!sfd.freq_list) {
400 rcu_read_unlock();
401 return -ENOMEM;
402 }
403
404 freq = 0;
405 for (i = 0; i < sfd.freq_cnt; i++) {
406#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
407 opp = sfd.pdata->opp_find_freq_ceil(dev, &freq);
408#else
409 opp = opp_find_freq_ceil(dev, &freq);
410#endif
411 if (IS_ERR_OR_NULL(opp)) {
412 rcu_read_unlock();
413 kfree(sfd.freq_list);
414 return -ENODEV;
415 }
416 sfd.freq_list[i] = freq;
417 freq++;
418 }
419 rcu_read_unlock();
420
421#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
422 sfd.core_clk = devm_clk_get(dev, "dpll_core_h14x2_ck");
423 if (IS_ERR(sfd.core_clk)) {
424 ret = PTR_ERR(sfd.core_clk);
425 pr_err("sgxfreq: failed to get core clock: %d\n", ret);
426 return ret;
427 }
428
429 sfd.gpu_clk = devm_clk_get(dev, "dpll_gpu_m2_ck");
430 if (IS_ERR(sfd.gpu_clk)) {
431 ret = PTR_ERR(sfd.gpu_clk);
432 pr_err("sgxfreq: failed to get gpu clock: %d\n", ret);
433 return ret;
434 }
435
436 sfd.per_clk = devm_clk_get(dev, "dpll_per_h14x2_ck");
437 if (IS_ERR(sfd.per_clk)) {
438 ret = PTR_ERR(sfd.per_clk);
439 pr_err("sgxfreq: failed to get per clock: %d\n", ret);
440 return ret;
441 }
442
443 sfd.gpu_core_clk = devm_clk_get(dev, "gpu_core_gclk_mux");
444 if (IS_ERR(sfd.gpu_core_clk)) {
445 ret = PTR_ERR(sfd.gpu_core_clk);
446 pr_err("sgxfreq: failed to get gpu core clock: %d\n", ret);
447 return ret;
448 }
449
450 sfd.gpu_hyd_clk = devm_clk_get(dev, "gpu_hyd_gclk_mux");
451 if (IS_ERR(sfd.gpu_hyd_clk)) {
452 ret = PTR_ERR(sfd.gpu_hyd_clk);
453 pr_err("sgxfreq: failed to get gpu hyd clock: %d\n", ret);
454 return ret;
455 }
456
457 sfd.gpu_reg = devm_regulator_get(dev, "gpu");
458 if (IS_ERR(sfd.gpu_reg)) {
459 if (PTR_ERR(sfd.gpu_reg) == -EPROBE_DEFER) {
460 dev_err(dev, "gpu regulator not ready, retry\n");
461 return -EPROBE_DEFER;
462 }
463 pr_err("sgxfreq: failed to get gpu regulator: %ld\n", PTR_ERR(sfd.gpu_reg));
464 sfd.gpu_reg = NULL;
465 }
466
467 ret = clk_set_parent(sfd.gpu_hyd_clk, sfd.core_clk);
468 if (ret != 0) {
469 pr_err("sgxfreq: failed to set gpu_hyd_clk parent: %d\n", ret);
470 }
471
472 ret = clk_set_parent(sfd.gpu_core_clk, sfd.core_clk);
473 if (ret != 0) {
474 pr_err("sgxfreq: failed to set gpu_core_clk parent: %d\n", ret);
475 }
476#endif
477
478 mutex_init(&sfd.freq_mutex);
479 sfd.freq_limit = sfd.freq_list[sfd.freq_cnt - 1];
480 sgxfreq_set_freq_request(sfd.freq_list[sfd.freq_cnt - 1]);
481 sfd.sgx_data.clk_on = false;
482 sfd.sgx_data.active = false;
483
484 mutex_init(&sfd.gov_mutex);
485 INIT_LIST_HEAD(&sfd.gov_list);
486
487 sgxfreq_kobj = kobject_create_and_add("sgxfreq", &sfd.dev->kobj);
488 ret = sysfs_create_files(sgxfreq_kobj, sgxfreq_attributes);
489 if (ret) {
490 kfree(sfd.freq_list);
491 return ret;
492 }
493
494#if (defined(CONFIG_THERMAL) || defined(CONFIG_THERMAL_FRAMEWORK))
495 cool_init();
496#endif
497
498 for (i = 0; sgxfreq_gov_init[i] != NULL; i++)
499 sgxfreq_gov_init[i]();
500
501 if (sgxfreq_set_governor(SGXFREQ_DEFAULT_GOV_NAME)) {
502 kfree(sfd.freq_list);
503 return -ENODEV;
504 }
505 do_gettimeofday(&tv);
506 _idle_prev_time = _active_curr_time = _idle_curr_time =
507 _active_prev_time = __tv2msec(tv);
508
509 return 0;
510}
511
512int sgxfreq_deinit(void)
513{
514 int i;
515
516 sgxfreq_set_governor(NULL);
517
518 sgxfreq_set_freq_request(sfd.freq_list[0]);
519
520#if (defined(CONFIG_THERMAL) || defined(CONFIG_THERMAL_FRAMEWORK))
521 cool_deinit();
522#endif
523
524 for (i = 0; sgxfreq_gov_deinit[i] != NULL; i++)
525 sgxfreq_gov_deinit[i]();
526
527 sysfs_remove_files(sgxfreq_kobj, sgxfreq_attributes);
528 kobject_put(sgxfreq_kobj);
529
530 kfree(sfd.freq_list);
531
532 return 0;
533}
534
535int sgxfreq_register_governor(struct sgxfreq_governor *governor)
536{
537 if (!governor)
538 return -EINVAL;
539
540 list_add(&governor->governor_list, &sfd.gov_list);
541
542 return 0;
543}
544
545void sgxfreq_unregister_governor(struct sgxfreq_governor *governor)
546{
547 if (!governor)
548 return;
549
550 list_del(&governor->governor_list);
551}
552
553int sgxfreq_set_governor(const char *name)
554{
555 int ret = 0;
556 struct sgxfreq_governor *new_gov = 0;
557
558 if (name) {
559 new_gov = __find_governor(name);
560 if (!new_gov)
561 return -EINVAL;
562 }
563
564 mutex_lock(&sfd.gov_mutex);
565
566 if (sfd.gov && sfd.gov->gov_stop)
567 sfd.gov->gov_stop();
568
569 if (new_gov && new_gov->gov_start)
570 ret = new_gov->gov_start(&sfd.sgx_data);
571
572 if (ret) {
573 if (sfd.gov && sfd.gov->gov_start)
574 sfd.gov->gov_start(&sfd.sgx_data);
575 return -ENODEV;
576 }
577 sfd.gov = new_gov;
578
579 mutex_unlock(&sfd.gov_mutex);
580
581 return 0;
582}
583
584int sgxfreq_get_freq_list(unsigned long **pfreq_list)
585{
586 *pfreq_list = sfd.freq_list;
587
588 return sfd.freq_cnt;
589}
590
591unsigned long sgxfreq_get_freq_min(void)
592{
593 return sfd.freq_list[0];
594}
595
596unsigned long sgxfreq_get_freq_max(void)
597{
598 return sfd.freq_list[sfd.freq_cnt - 1];
599}
600
601unsigned long sgxfreq_get_freq_floor(unsigned long freq)
602{
603 int i;
604 unsigned long f = 0;
605
606 for (i = sfd.freq_cnt - 1; i >= 0; i--) {
607 f = sfd.freq_list[i];
608 if (f <= freq)
609 return f;
610 }
611
612 return f;
613}
614
615unsigned long sgxfreq_get_freq_ceil(unsigned long freq)
616{
617 int i;
618 unsigned long f = 0;
619
620 for (i = 0; i < sfd.freq_cnt; i++) {
621 f = sfd.freq_list[i];
622 if (f >= freq)
623 return f;
624 }
625
626 return f;
627}
628
629unsigned long sgxfreq_get_freq(void)
630{
631 return sfd.freq;
632}
633
634unsigned long sgxfreq_get_freq_request(void)
635{
636 return sfd.freq_request;
637}
638
639unsigned long sgxfreq_get_freq_limit(void)
640{
641 return sfd.freq_limit;
642}
643
644unsigned long sgxfreq_set_freq_request(unsigned long freq_request)
645{
646 freq_request = sgxfreq_get_freq_ceil(freq_request);
647
648 mutex_lock(&sfd.freq_mutex);
649
650 sfd.freq_request = freq_request;
651 __set_freq();
652
653 mutex_unlock(&sfd.freq_mutex);
654
655 return freq_request;
656}
657
658unsigned long sgxfreq_set_freq_limit(unsigned long freq_limit)
659{
660 freq_limit = sgxfreq_get_freq_ceil(freq_limit);
661
662 mutex_lock(&sfd.freq_mutex);
663
664 sfd.freq_limit = freq_limit;
665 __set_freq();
666
667 mutex_unlock(&sfd.freq_mutex);
668
669 return freq_limit;
670}
671
672unsigned long sgxfreq_get_total_active_time(void)
673{
674 __update_timing_info(sfd.sgx_data.active);
675 return sfd.total_active_time;
676}
677
678unsigned long sgxfreq_get_total_idle_time(void)
679{
680 __update_timing_info(sfd.sgx_data.active);
681 return sfd.total_idle_time;
682}
683
684/*
685 * sgx_clk_on, sgx_clk_off, sgx_active, and sgx_idle notifications are
686 * serialized by power lock. governor notif calls need sync with governor
687 * setting.
688 */
689void sgxfreq_notif_sgx_clk_on(void)
690{
691 sfd.sgx_data.clk_on = true;
692
693 mutex_lock(&sfd.gov_mutex);
694
695 if (sfd.gov && sfd.gov->sgx_clk_on)
696 sfd.gov->sgx_clk_on();
697
698 mutex_unlock(&sfd.gov_mutex);
699}
700
701void sgxfreq_notif_sgx_clk_off(void)
702{
703 sfd.sgx_data.clk_on = false;
704
705 mutex_lock(&sfd.gov_mutex);
706
707 if (sfd.gov && sfd.gov->sgx_clk_off)
708 sfd.gov->sgx_clk_off();
709
710 mutex_unlock(&sfd.gov_mutex);
711}
712
713
714void sgxfreq_notif_sgx_active(void)
715{
716 __update_timing_info(true);
717
718 sfd.sgx_data.active = true;
719
720 mutex_lock(&sfd.gov_mutex);
721
722 if (sfd.gov && sfd.gov->sgx_active)
723 sfd.gov->sgx_active();
724
725 mutex_unlock(&sfd.gov_mutex);
726
727}
728
729void sgxfreq_notif_sgx_idle(void)
730{
731
732 __update_timing_info(false);
733
734 sfd.sgx_data.active = false;
735
736 mutex_lock(&sfd.gov_mutex);
737
738 if (sfd.gov && sfd.gov->sgx_idle)
739 sfd.gov->sgx_idle();
740
741 mutex_unlock(&sfd.gov_mutex);
742}
743
744void sgxfreq_notif_sgx_frame_done(void)
745{
746 mutex_lock(&sfd.gov_mutex);
747
748 if (sfd.gov && sfd.gov->sgx_frame_done)
749 sfd.gov->sgx_frame_done();
750
751 mutex_unlock(&sfd.gov_mutex);
752}
diff --git a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq.h b/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq.h
deleted file mode 100644
index ff6fc88..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq.h
+++ /dev/null
@@ -1,97 +0,0 @@
1/*
2 * Copyright (C) 2012 Texas Instruments, Inc
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef SGXFREQ_H
18#define SGXFREQ_H
19
20#include <linux/device.h>
21#include <linux/time.h>
22
23#define SGXFREQ_NAME_LEN 16
24
25//#define SGXFREQ_DEBUG_FTRACE
26#if defined(SGXFREQ_DEBUG_FTRACE)
27#define SGXFREQ_TRACE(...) trace_printk(__VA_ARGS__)
28#else
29#define SGXFREQ_TRACE(...)
30#endif
31
32struct sgxfreq_sgx_data {
33 bool clk_on;
34 bool active;
35};
36
37struct sgxfreq_governor {
38 char name[SGXFREQ_NAME_LEN];
39 int (*gov_start) (struct sgxfreq_sgx_data *data);
40 void (*gov_stop) (void);
41 void (*sgx_clk_on) (void);
42 void (*sgx_clk_off) (void);
43 void (*sgx_active) (void);
44 void (*sgx_idle) (void);
45 void (*sgx_frame_done) (void);
46 struct list_head governor_list;
47};
48
49/* sgxfreq_init must be called before any other api */
50int sgxfreq_init(struct device *dev);
51int sgxfreq_deinit(void);
52
53int sgxfreq_register_governor(struct sgxfreq_governor *governor);
54void sgxfreq_unregister_governor(struct sgxfreq_governor *governor);
55
56int sgxfreq_set_governor(const char *name);
57
58int sgxfreq_get_freq_list(unsigned long **pfreq_list);
59
60unsigned long sgxfreq_get_freq_min(void);
61unsigned long sgxfreq_get_freq_max(void);
62
63unsigned long sgxfreq_get_freq_floor(unsigned long freq);
64unsigned long sgxfreq_get_freq_ceil(unsigned long freq);
65
66unsigned long sgxfreq_get_freq(void);
67unsigned long sgxfreq_get_freq_request(void);
68unsigned long sgxfreq_get_freq_limit(void);
69
70unsigned long sgxfreq_set_freq_request(unsigned long freq_request);
71unsigned long sgxfreq_set_freq_limit(unsigned long freq_limit);
72
73unsigned long sgxfreq_get_total_active_time(void);
74unsigned long sgxfreq_get_total_idle_time(void);
75
76/* Helper functions */
77static inline unsigned long __tv2msec(struct timeval tv)
78{
79 return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
80}
81
82static inline unsigned long __delta32(unsigned long a, unsigned long b)
83{
84 if (a >= b)
85 return a - b;
86 else
87 return 1 + (0xFFFFFFFF - b) + a;
88}
89
90/* External notifications to sgxfreq */
91void sgxfreq_notif_sgx_clk_on(void);
92void sgxfreq_notif_sgx_clk_off(void);
93void sgxfreq_notif_sgx_active(void);
94void sgxfreq_notif_sgx_idle(void);
95void sgxfreq_notif_sgx_frame_done(void);
96
97#endif
diff --git a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_activeidle.c b/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_activeidle.c
deleted file mode 100644
index 45159d7..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_activeidle.c
+++ /dev/null
@@ -1,181 +0,0 @@
1/*
2 * Copyright (C) 2012 Texas Instruments, Inc
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <linux/sysfs.h>
18#include "sgxfreq.h"
19
20static int activeidle_start(struct sgxfreq_sgx_data *data);
21static void activeidle_stop(void);
22static void activeidle_sgx_active(void);
23static void activeidle_sgx_idle(void);
24
25static struct activeidle_data {
26 unsigned long freq_active;
27 unsigned long freq_idle;
28 struct mutex mutex;
29 bool sgx_active;
30} aid;
31
32static struct sgxfreq_governor activeidle_gov = {
33 .name = "activeidle",
34 .gov_start = activeidle_start,
35 .gov_stop = activeidle_stop,
36 .sgx_active = activeidle_sgx_active,
37 .sgx_idle = activeidle_sgx_idle,
38};
39
40/*********************** begin sysfs interface ***********************/
41
42extern struct kobject *sgxfreq_kobj;
43
44static ssize_t show_freq_active(struct device *dev,
45 struct device_attribute *attr,
46 char *buf)
47{
48 return sprintf(buf, "%lu\n", aid.freq_active);
49}
50
51static ssize_t store_freq_active(struct device *dev,
52 struct device_attribute *attr,
53 const char *buf, size_t count)
54{
55 int ret;
56 unsigned long freq;
57
58 ret = sscanf(buf, "%lu", &freq);
59 if (ret != 1)
60 return -EINVAL;
61
62 freq = sgxfreq_get_freq_ceil(freq);
63
64 mutex_lock(&aid.mutex);
65
66 aid.freq_active = freq;
67 if (aid.sgx_active)
68 sgxfreq_set_freq_request(aid.freq_active);
69
70 mutex_unlock(&aid.mutex);
71
72 return count;
73}
74
75static ssize_t show_freq_idle(struct device *dev, struct device_attribute *attr,
76 char *buf)
77{
78 return sprintf(buf, "%lu\n", aid.freq_idle);
79}
80
81static ssize_t store_freq_idle(struct device *dev, struct device_attribute *attr,
82 const char *buf, size_t count)
83{
84 int ret;
85 unsigned long freq;
86
87 ret = sscanf(buf, "%lu", &freq);
88 if (ret != 1)
89 return -EINVAL;
90
91 freq = sgxfreq_get_freq_floor(freq);
92
93 mutex_lock(&aid.mutex);
94
95 aid.freq_idle = freq;
96 if (!aid.sgx_active)
97 sgxfreq_set_freq_request(aid.freq_idle);
98
99 mutex_unlock(&aid.mutex);
100
101 return count;
102}
103static DEVICE_ATTR(freq_active, 0644, show_freq_active, store_freq_active);
104static DEVICE_ATTR(freq_idle, 0644, show_freq_idle, store_freq_idle);
105
106static struct attribute *activeidle_attributes[] = {
107 &dev_attr_freq_active.attr,
108 &dev_attr_freq_idle.attr,
109 NULL
110};
111
112static struct attribute_group activeidle_attr_group = {
113 .attrs = activeidle_attributes,
114 .name = "activeidle",
115};
116
117/************************ end sysfs interface ************************/
118
119int activeidle_init(void)
120{
121 int ret;
122
123 mutex_init(&aid.mutex);
124
125 ret = sgxfreq_register_governor(&activeidle_gov);
126 if (ret)
127 return ret;
128
129 aid.freq_idle = sgxfreq_get_freq_min();
130 aid.freq_active = sgxfreq_get_freq_max();
131
132 return 0;
133}
134
135int activeidle_deinit(void)
136{
137 return 0;
138}
139
140static int activeidle_start(struct sgxfreq_sgx_data *data)
141{
142 int ret;
143
144 aid.sgx_active = data->active;
145
146 ret = sysfs_create_group(sgxfreq_kobj, &activeidle_attr_group);
147 if (ret)
148 return ret;
149
150 if (aid.sgx_active)
151 sgxfreq_set_freq_request(aid.freq_active);
152 else
153 sgxfreq_set_freq_request(aid.freq_idle);
154
155 return 0;
156}
157
158static void activeidle_stop(void)
159{
160 sysfs_remove_group(sgxfreq_kobj, &activeidle_attr_group);
161}
162
163static void activeidle_sgx_active(void)
164{
165 mutex_lock(&aid.mutex);
166
167 aid.sgx_active = true;
168 sgxfreq_set_freq_request(aid.freq_active);
169
170 mutex_unlock(&aid.mutex);
171}
172
173static void activeidle_sgx_idle(void)
174{
175 mutex_lock(&aid.mutex);
176
177 aid.sgx_active = false;
178 sgxfreq_set_freq_request(aid.freq_idle);
179
180 mutex_unlock(&aid.mutex);
181}
diff --git a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_cool.c b/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_cool.c
deleted file mode 100644
index a58eb39..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_cool.c
+++ /dev/null
@@ -1,191 +0,0 @@
1/*
2 * Copyright (C) 2012 Texas Instruments, Inc
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
18
19#include <linux/thermal.h>
20
21static struct cool_data {
22 int freq_cnt;
23 unsigned long *freq_list;
24 unsigned long state;
25 struct thermal_cooling_device *cdev;
26} cd;
27
28static int sgxfreq_get_max_state(struct thermal_cooling_device *cdev,
29 unsigned long *state)
30{
31 *state = cd.freq_cnt - 1;
32 return 0;
33}
34
35static int sgxfreq_get_cur_state(struct thermal_cooling_device *cdev,
36 unsigned long *state)
37{
38 *state = cd.state;
39 return 0;
40}
41
42static int sgxfreq_set_cur_state(struct thermal_cooling_device *cdev,
43 unsigned long state)
44{
45 int freq_max_index, freq_limit_index;
46
47 freq_max_index = cd.freq_cnt - 1;
48
49 freq_limit_index = freq_max_index - (unsigned int)state;
50
51 if (freq_limit_index < 0)
52 freq_limit_index = 0;
53
54 sgxfreq_set_freq_limit(cd.freq_list[freq_limit_index]);
55
56 cd.state = state;
57 return 0;
58}
59
60
61static const struct thermal_cooling_device_ops sgxfreq_cooling_ops = {
62 .get_max_state = sgxfreq_get_max_state,
63 .get_cur_state = sgxfreq_get_cur_state,
64 .set_cur_state = sgxfreq_set_cur_state,
65};
66
67int cool_init(void)
68{
69 int ret;
70 struct thermal_zone_device *tz;
71
72 cd.freq_cnt = sgxfreq_get_freq_list(&cd.freq_list);
73 if (!cd.freq_cnt || !cd.freq_list)
74 return -EINVAL;
75
76 cd.cdev = thermal_cooling_device_register("gpu", (void *)NULL, &sgxfreq_cooling_ops);
77
78 if(IS_ERR(cd.cdev)) {
79 pr_err("sgxfreq: Error while regeistering cooling device: %ld\n", PTR_ERR(cd.cdev));
80 return -1;
81 }
82
83 tz = thermal_zone_get_zone_by_name("gpu");
84 if(IS_ERR(tz)) {
85 pr_err("sgxfreq: Error while trying to obtain zone device: %ld\n", PTR_ERR(tz));
86 return -1;
87 }
88
89 ret = thermal_zone_bind_cooling_device(tz, 0, cd.cdev, THERMAL_NO_LIMIT, THERMAL_NO_LIMIT);
90 if (ret)
91 {
92 pr_err("sgxfreq: Error binding cooling device: %d\n", ret);
93 }
94
95 return 0;
96}
97
98void cool_deinit(void)
99{
100 thermal_cooling_device_unregister(cd.cdev);
101}
102#else //if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
103#include <linux/thermal_framework.h>
104
105static int cool_device(struct thermal_dev *dev, int cooling_level);
106
107static struct cool_data {
108 int freq_cnt;
109 unsigned long *freq_list;
110} cd;
111
112static struct thermal_dev_ops cool_dev_ops = {
113 .cool_device = cool_device,
114};
115
116static struct thermal_dev cool_dev = {
117 .name = "gpu_cooling.0",
118 .domain_name = "gpu",
119 .dev_ops = &cool_dev_ops,
120};
121
122static struct thermal_dev case_cool_dev = {
123 .name = "gpu_cooling.1",
124 .domain_name = "case",
125 .dev_ops = &cool_dev_ops,
126};
127
128static unsigned int gpu_cooling_level;
129#if defined(CONFIG_CASE_TEMP_GOVERNOR)
130static unsigned int case_cooling_level;
131#endif
132
133int cool_init(void)
134{
135 int ret;
136 cd.freq_cnt = sgxfreq_get_freq_list(&cd.freq_list);
137 if (!cd.freq_cnt || !cd.freq_list)
138 return -EINVAL;
139
140 ret = thermal_cooling_dev_register(&cool_dev);
141 if (ret)
142 return ret;
143
144 return thermal_cooling_dev_register(&case_cool_dev);
145}
146
147void cool_deinit(void)
148{
149 thermal_cooling_dev_unregister(&cool_dev);
150 thermal_cooling_dev_unregister(&case_cool_dev);
151}
152
153static int cool_device(struct thermal_dev *dev, int cooling_level)
154{
155 int freq_max_index, freq_limit_index;
156
157#if defined(CONFIG_CASE_TEMP_GOVERNOR)
158 if (!strcmp(dev->domain_name, "case"))
159 {
160 int tmp = 0;
161 tmp = cooling_level - case_subzone_number;
162 if (tmp < 0)
163 tmp = 0;
164 case_cooling_level = tmp;
165 }
166 else
167#endif
168 {
169 gpu_cooling_level = cooling_level;
170 }
171
172 freq_max_index = cd.freq_cnt - 1;
173#if defined(CONFIG_CASE_TEMP_GOVERNOR)
174 if (case_cooling_level > gpu_cooling_level)
175 {
176 freq_limit_index = freq_max_index - case_cooling_level;
177 }
178 else
179#endif
180 {
181 freq_limit_index = freq_max_index - gpu_cooling_level;
182 }
183
184 if (freq_limit_index < 0)
185 freq_limit_index = 0;
186
187 sgxfreq_set_freq_limit(cd.freq_list[freq_limit_index]);
188
189 return 0;
190}
191#endif //if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
diff --git a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_on3demand.c b/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_on3demand.c
deleted file mode 100644
index c4e4bd9..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_on3demand.c
+++ /dev/null
@@ -1,324 +0,0 @@
1/*
2 * Copyright (C) 2012 Texas Instruments, Inc
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <linux/sysfs.h>
18#include <linux/vmalloc.h>
19#include <asm/io.h>
20#include "sgxfreq.h"
21
22static int on3demand_start(struct sgxfreq_sgx_data *data);
23static void on3demand_stop(void);
24static void on3demand_predict(void);
25static void on3demand_frame_done(void);
26static void on3demand_active(void);
27static void on3demand_timeout(struct work_struct *work);
28
29
30static struct sgxfreq_governor on3demand_gov = {
31 .name = "on3demand",
32 .gov_start = on3demand_start,
33 .gov_stop = on3demand_stop,
34 .sgx_frame_done = on3demand_frame_done,
35 .sgx_active = on3demand_active,
36};
37
38static struct on3demand_data {
39 unsigned int load;
40 unsigned int up_threshold;
41 unsigned int down_threshold;
42 unsigned int history_size;
43 unsigned long prev_total_idle;
44 unsigned long prev_total_active;
45 unsigned int low_load_cnt;
46 unsigned int poll_interval;
47 unsigned long delta_active;
48 unsigned long delta_idle;
49 bool polling_enabled;
50 struct delayed_work work;
51 struct mutex mutex;
52} odd;
53
54#define ON3DEMAND_DEFAULT_UP_THRESHOLD 80
55#define ON3DEMAND_DEFAULT_DOWN_THRESHOLD 30
56#define ON3DEMAND_DEFAULT_HISTORY_SIZE_THRESHOLD 5
57/* For Live wallpaper frame done at interval of ~64ms */
58#define ON3DEMAND_DEFAULT_POLL_INTERVAL 75
59
60/*FIXME: This should be dynamic and queried from platform */
61#define ON3DEMAND_FRAME_DONE_DEADLINE_MS 16
62
63
64/*********************** begin sysfs interface ***********************/
65
66extern struct kobject *sgxfreq_kobj;
67
68static ssize_t show_down_threshold(struct device *dev,
69 struct device_attribute *attr, char *buf)
70{
71 return sprintf(buf, "%u\n", odd.down_threshold);
72}
73
74static ssize_t store_down_threshold(struct device *dev,
75 struct device_attribute *attr, const char *buf, size_t count)
76{
77 int ret;
78 unsigned int thres;
79
80 ret = sscanf(buf, "%u", &thres);
81 if (ret != 1)
82 return -EINVAL;
83
84 mutex_lock(&odd.mutex);
85
86 if (thres <= 100) {
87 odd.down_threshold = thres;
88 odd.low_load_cnt = 0;
89 } else {
90 return -EINVAL;
91 }
92
93 mutex_unlock(&odd.mutex);
94
95 return count;
96}
97
98static ssize_t show_up_threshold(struct device *dev,
99 struct device_attribute *attr, char *buf)
100{
101 return sprintf(buf, "%u\n", odd.up_threshold);
102}
103
104static ssize_t store_up_threshold(struct device *dev,
105 struct device_attribute *attr, const char *buf, size_t count)
106{
107 int ret;
108 unsigned int thres;
109
110 ret = sscanf(buf, "%u", &thres);
111 if (ret != 1)
112 return -EINVAL;
113
114 mutex_lock(&odd.mutex);
115
116 if (thres <= 100) {
117 odd.up_threshold = thres;
118 odd.low_load_cnt = 0;
119 } else {
120 return -EINVAL;
121 }
122
123 mutex_unlock(&odd.mutex);
124
125 return count;
126}
127
128static ssize_t show_history_size(struct device *dev,
129 struct device_attribute *attr, char *buf)
130{
131 return sprintf(buf, "%u\n", odd.history_size);
132}
133
134static ssize_t store_history_size(struct device *dev,
135 struct device_attribute *attr, const char *buf, size_t count)
136{
137 int ret;
138 unsigned int size;
139
140 ret = sscanf(buf, "%u", &size);
141 if (ret != 1)
142 return -EINVAL;
143
144 mutex_lock(&odd.mutex);
145
146 if (size >= 1) {
147 odd.history_size = size;
148 odd.low_load_cnt = 0;
149 } else {
150 return -EINVAL;
151 }
152
153 mutex_unlock(&odd.mutex);
154
155 return count;
156}
157
158static ssize_t show_load(struct device *dev,
159 struct device_attribute *attr, char *buf)
160{
161 return sprintf(buf, "%u\n", odd.load);
162}
163
164static DEVICE_ATTR(down_threshold, 0644,
165 show_down_threshold, store_down_threshold);
166static DEVICE_ATTR(up_threshold, 0644,
167 show_up_threshold, store_up_threshold);
168static DEVICE_ATTR(history_size, 0644,
169 show_history_size, store_history_size);
170static DEVICE_ATTR(load, 0444,
171 show_load, NULL);
172
173static struct attribute *on3demand_attributes[] = {
174 &dev_attr_down_threshold.attr,
175 &dev_attr_up_threshold.attr,
176 &dev_attr_history_size.attr,
177 &dev_attr_load.attr,
178 NULL
179};
180
181static struct attribute_group on3demand_attr_group = {
182 .attrs = on3demand_attributes,
183 .name = "on3demand",
184};
185/************************ end sysfs interface ************************/
186
187int on3demand_init(void)
188{
189 int ret;
190
191 mutex_init(&odd.mutex);
192
193 ret = sgxfreq_register_governor(&on3demand_gov);
194 if (ret)
195 return ret;
196
197 return 0;
198}
199
200int on3demand_deinit(void)
201{
202 return 0;
203}
204
205static int on3demand_start(struct sgxfreq_sgx_data *data)
206{
207 int ret;
208
209 odd.load = 0;
210 odd.up_threshold = ON3DEMAND_DEFAULT_UP_THRESHOLD;
211 odd.down_threshold = ON3DEMAND_DEFAULT_DOWN_THRESHOLD;
212 odd.history_size = ON3DEMAND_DEFAULT_HISTORY_SIZE_THRESHOLD;
213 odd.prev_total_active = 0;
214 odd.prev_total_idle = 0;
215 odd.low_load_cnt = 0;
216 odd.poll_interval = ON3DEMAND_DEFAULT_POLL_INTERVAL;
217 odd.polling_enabled = false;
218
219 INIT_DELAYED_WORK(&odd.work, on3demand_timeout);
220
221 ret = sysfs_create_group(sgxfreq_kobj, &on3demand_attr_group);
222 if (ret)
223 return ret;
224
225 return 0;
226}
227
228static void on3demand_stop(void)
229{
230 cancel_delayed_work_sync(&odd.work);
231 sysfs_remove_group(sgxfreq_kobj, &on3demand_attr_group);
232}
233
234static void on3demand_predict(void)
235{
236 static unsigned short first_sample = 1;
237 unsigned long total_active, total_idle;
238 unsigned long freq;
239
240 if (first_sample == 1) {
241 first_sample = 0;
242 odd.prev_total_active = sgxfreq_get_total_active_time();
243 odd.prev_total_idle = sgxfreq_get_total_idle_time();
244 return;
245 }
246
247 /* Sample new active and idle times */
248 total_active = sgxfreq_get_total_active_time();
249 total_idle = sgxfreq_get_total_idle_time();
250
251 /* Compute load */
252 odd.delta_active = __delta32(total_active, odd.prev_total_active);
253 odd.delta_idle = __delta32(total_idle, odd.prev_total_idle);
254
255 /*
256 * If SGX was active for longer than frame display time (1/fps),
257 * scale to highest possible frequency.
258 */
259 if (odd.delta_active > ON3DEMAND_FRAME_DONE_DEADLINE_MS) {
260 odd.low_load_cnt = 0;
261 sgxfreq_set_freq_request(sgxfreq_get_freq_max());
262 }
263
264 if ((odd.delta_active + odd.delta_idle))
265 odd.load = (100 * odd.delta_active / (odd.delta_active + odd.delta_idle));
266
267 odd.prev_total_active = total_active;
268 odd.prev_total_idle = total_idle;
269
270 /* Scale GPU frequency on purpose */
271 if (odd.load >= odd.up_threshold) {
272 odd.low_load_cnt = 0;
273 sgxfreq_set_freq_request(sgxfreq_get_freq_max());
274 } else if (odd.load <= odd.down_threshold) {
275 if (odd.low_load_cnt == odd.history_size) {
276 /* Convert load to frequency */
277 freq = (sgxfreq_get_freq() * odd.load) / 100;
278 sgxfreq_set_freq_request(freq);
279 odd.low_load_cnt = 0;
280 } else {
281 odd.low_load_cnt++;
282 }
283 } else {
284 odd.low_load_cnt = 0;
285 }
286}
287
288
289static void on3demand_active(void)
290{
291 if (!odd.polling_enabled) {
292 sgxfreq_set_freq_request(sgxfreq_get_freq_max());
293 odd.low_load_cnt = 0;
294 odd.polling_enabled = true;
295 schedule_delayed_work(&odd.work, odd.poll_interval * HZ/1000);
296 }
297
298}
299
300static void on3demand_frame_done(void)
301{
302 if (odd.polling_enabled) {
303 cancel_delayed_work_sync(&odd.work);
304 schedule_delayed_work(&odd.work, odd.poll_interval * HZ/1000);
305 }
306 on3demand_predict();
307}
308
309static void on3demand_timeout(struct work_struct *work)
310{
311 /*
312 * If sgx was idle all throughout timer disable polling and
313 * enable it on next sgx active event
314 */
315 if (!odd.delta_active) {
316 sgxfreq_set_freq_request(sgxfreq_get_freq_min());
317 odd.low_load_cnt = 0;
318 odd.polling_enabled = false;
319 } else {
320 on3demand_predict();
321 odd.polling_enabled = true;
322 schedule_delayed_work(&odd.work, odd.poll_interval * HZ/1000);
323 }
324}
diff --git a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_onoff.c b/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_onoff.c
deleted file mode 100644
index 39dd3fc..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_onoff.c
+++ /dev/null
@@ -1,180 +0,0 @@
1/*
2 * Copyright (C) 2012 Texas Instruments, Inc
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <linux/sysfs.h>
18#include "sgxfreq.h"
19
20static int onoff_start(struct sgxfreq_sgx_data *data);
21static void onoff_stop(void);
22static void onoff_sgx_clk_on(void);
23static void onoff_sgx_clk_off(void);
24
25static struct onoff_data {
26 unsigned long freq_off;
27 unsigned long freq_on;
28 struct mutex mutex;
29 bool sgx_clk_on;
30} ood;
31
32static struct sgxfreq_governor onoff_gov = {
33 .name = "onoff",
34 .gov_start = onoff_start,
35 .gov_stop = onoff_stop,
36 .sgx_clk_on = onoff_sgx_clk_on,
37 .sgx_clk_off = onoff_sgx_clk_off,
38};
39
40/*********************** begin sysfs interface ***********************/
41
42extern struct kobject *sgxfreq_kobj;
43
44static ssize_t show_freq_on(struct device *dev, struct device_attribute *attr,
45 char *buf)
46{
47 return sprintf(buf, "%lu\n", ood.freq_on);
48}
49
50static ssize_t store_freq_on(struct device *dev, struct device_attribute *attr,
51 const char *buf, size_t count)
52{
53 int ret;
54 unsigned long freq;
55
56 ret = sscanf(buf, "%lu", &freq);
57 if (ret != 1)
58 return -EINVAL;
59
60 freq = sgxfreq_get_freq_ceil(freq);
61
62 mutex_lock(&ood.mutex);
63
64 ood.freq_on = freq;
65 if (ood.sgx_clk_on)
66 sgxfreq_set_freq_request(ood.freq_on);
67
68 mutex_unlock(&ood.mutex);
69
70 return count;
71}
72
73static ssize_t show_freq_off(struct device *dev, struct device_attribute *attr,
74 char *buf)
75{
76 return sprintf(buf, "%lu\n", ood.freq_off);
77}
78
79static ssize_t store_freq_off(struct device *dev, struct device_attribute *attr,
80 const char *buf, size_t count)
81{
82 int ret;
83 unsigned long freq;
84
85 ret = sscanf(buf, "%lu", &freq);
86 if (ret != 1)
87 return -EINVAL;
88
89 freq = sgxfreq_get_freq_floor(freq);
90
91 mutex_lock(&ood.mutex);
92
93 ood.freq_off = freq;
94 if (!ood.sgx_clk_on)
95 sgxfreq_set_freq_request(ood.freq_off);
96
97 mutex_unlock(&ood.mutex);
98
99 return count;
100}
101static DEVICE_ATTR(freq_on, 0644, show_freq_on, store_freq_on);
102static DEVICE_ATTR(freq_off, 0644, show_freq_off, store_freq_off);
103
104static struct attribute *onoff_attributes[] = {
105 &dev_attr_freq_on.attr,
106 &dev_attr_freq_off.attr,
107 NULL
108};
109
110static struct attribute_group onoff_attr_group = {
111 .attrs = onoff_attributes,
112 .name = "onoff",
113};
114
115/************************ end sysfs interface ************************/
116
117int onoff_init(void)
118{
119 int ret;
120
121 mutex_init(&ood.mutex);
122
123 ret = sgxfreq_register_governor(&onoff_gov);
124 if (ret)
125 return ret;
126
127 ood.freq_off = sgxfreq_get_freq_min();
128 ood.freq_on = sgxfreq_get_freq_max();
129
130 return 0;
131}
132
133int onoff_deinit(void)
134{
135 return 0;
136}
137
138static int onoff_start(struct sgxfreq_sgx_data *data)
139{
140 int ret;
141
142 ood.sgx_clk_on = data->clk_on;
143
144 ret = sysfs_create_group(sgxfreq_kobj, &onoff_attr_group);
145 if (ret)
146 return ret;
147
148 if (ood.sgx_clk_on)
149 sgxfreq_set_freq_request(ood.freq_on);
150 else
151 sgxfreq_set_freq_request(ood.freq_off);
152
153 return 0;
154}
155
156static void onoff_stop(void)
157{
158 sysfs_remove_group(sgxfreq_kobj, &onoff_attr_group);
159}
160
161static void onoff_sgx_clk_on(void)
162{
163 mutex_lock(&ood.mutex);
164
165 ood.sgx_clk_on = true;
166 sgxfreq_set_freq_request(ood.freq_on);
167
168 mutex_unlock(&ood.mutex);
169}
170
171static void onoff_sgx_clk_off(void)
172{
173 mutex_lock(&ood.mutex);
174
175 ood.sgx_clk_on = false;
176 sgxfreq_set_freq_request(ood.freq_off);
177
178 mutex_unlock(&ood.mutex);
179}
180
diff --git a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_userspace.c b/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_userspace.c
deleted file mode 100644
index aff6087..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sgxfreq_userspace.c
+++ /dev/null
@@ -1,124 +0,0 @@
1/*
2 * Copyright (C) 2012 Texas Instruments, Inc
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <linux/sysfs.h>
18#include "sgxfreq.h"
19
20
21static int userspace_start(struct sgxfreq_sgx_data *data);
22static void userspace_stop(void);
23
24
25static struct sgxfreq_governor userspace_gov = {
26 .name = "userspace",
27 .gov_start = userspace_start,
28 .gov_stop = userspace_stop,
29};
30
31
32static struct userspace_data {
33 unsigned long freq_user; /* in Hz */
34} usd;
35
36
37/*********************** begin sysfs interface ***********************/
38
39extern struct kobject *sgxfreq_kobj;
40
41
42static ssize_t show_frequency_set(struct device *dev, struct device_attribute *attr,
43 char *buf)
44{
45 return sprintf(buf, "%lu\n", usd.freq_user);
46}
47
48
49static ssize_t store_frequency_set(struct device *dev,
50 struct device_attribute *attr, const char *buf, size_t count)
51{
52 int ret;
53 unsigned long freq;
54
55 ret = sscanf(buf, "%lu", &freq);
56 if (ret != 1)
57 return -EINVAL;
58
59 if (freq > sgxfreq_get_freq_max())
60 freq = sgxfreq_get_freq_max();
61 usd.freq_user = sgxfreq_set_freq_request(freq);
62 trace_printk("USERSPACE: new freq=%luHz.\n", usd.freq_user);
63
64 return count;
65}
66
67
68static DEVICE_ATTR(frequency_set, 0644,
69 show_frequency_set, store_frequency_set);
70
71
72static struct attribute *userspace_attributes[] = {
73 &dev_attr_frequency_set.attr,
74 NULL
75};
76
77
78static struct attribute_group userspace_attr_group = {
79 .attrs = userspace_attributes,
80 .name = "userspace",
81};
82
83/************************ end sysfs interface ************************/
84
85
86int userspace_init(void)
87{
88 int ret;
89
90 ret = sgxfreq_register_governor(&userspace_gov);
91 if (ret)
92 return ret;
93 return 0;
94}
95
96
97int userspace_deinit(void)
98{
99 return 0;
100}
101
102
103static int userspace_start(struct sgxfreq_sgx_data *data)
104{
105 int ret;
106
107 usd.freq_user = sgxfreq_get_freq();
108
109 ret = sysfs_create_group(sgxfreq_kobj, &userspace_attr_group);
110 if (ret)
111 return ret;
112
113 trace_printk("USERSPACE: started.\n");
114
115 return 0;
116}
117
118
119static void userspace_stop(void)
120{
121 sysfs_remove_group(sgxfreq_kobj, &userspace_attr_group);
122
123 trace_printk("USERSPACE: stopped.\n");
124}
diff --git a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysconfig.c b/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysconfig.c
deleted file mode 100644
index 175252d..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysconfig.c
+++ /dev/null
@@ -1,1333 +0,0 @@
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
6
7The contents of this file are subject to the MIT license as set out below.
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19Alternatively, the contents of this file may be used under the terms of
20the GNU General Public License Version 2 ("GPL") in which case the provisions
21of GPL are applicable instead of those above.
22
23If you wish to allow use of your version of this file only under the terms of
24GPL, and not to allow others to use your version of this file under the terms
25of the MIT license, indicate your decision by deleting the provisions above
26and replace them with the notice and other provisions required by GPL as set
27out in the file called "GPL-COPYING" included in this distribution. If you do
28not delete the provisions above, a recipient may use your version of this file
29under the terms of either the MIT license or GPL.
30
31This License is also included in this distribution in the file called
32"MIT-COPYING".
33
34EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
35PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
38COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41*/ /**************************************************************************/
42
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"
50
51#include "ocpdefs.h"
52
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
58
59/* top level system data anchor point*/
60SYS_DATA* gpsSysData = (SYS_DATA*)IMG_NULL;
61SYS_DATA gsSysData;
62
63static SYS_SPECIFIC_DATA gsSysSpecificData;
64SYS_SPECIFIC_DATA *gpsSysSpecificData;
65
66/* SGX structures */
67static IMG_UINT32 gui32SGXDeviceID;
68static SGX_DEVICE_MAP gsSGXDeviceMap;
69static PVRSRV_DEVICE_NODE *gpsSGXDevNode;
70
71
72#if defined(NO_HARDWARE) || defined(SGX_OCP_REGS_ENABLED)
73static IMG_CPU_VIRTADDR gsSGXRegsCPUVAddr;
74#endif
75
76#if defined(PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO)
77extern struct platform_device *gpsPVRLDMDev;
78#endif
79
80IMG_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);
86
87#if defined(SGX_OCP_REGS_ENABLED)
88
89static IMG_CPU_VIRTADDR gpvOCPRegsLinAddr;
90
91static PVRSRV_ERROR EnableSGXClocksWrap(SYS_DATA *psSysData)
92{
93 PVRSRV_ERROR eError = EnableSGXClocks(psSysData);
94
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}
104
105#else /* defined(SGX_OCP_REGS_ENABLED) */
106
107static INLINE PVRSRV_ERROR EnableSGXClocksWrap(SYS_DATA *psSysData)
108{
109 return EnableSGXClocks(psSysData);
110}
111
112#endif /* defined(SGX_OCP_REGS_ENABLED) */
113
114static INLINE PVRSRV_ERROR EnableSystemClocksWrap(SYS_DATA *psSysData)
115{
116 PVRSRV_ERROR eError = EnableSystemClocks(psSysData);
117
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
132
133 return eError;
134}
135
136/*!
137******************************************************************************
138
139 @Function SysLocateDevices
140
141 @Description Specifies devices in the systems memory map
142
143 @Input psSysData - sys data
144
145 @Return PVRSRV_ERROR
146
147******************************************************************************/
148static 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
159
160 PVR_UNREFERENCED_PARAMETER(psSysData);
161
162 /* SGX Device: */
163 gsSGXDeviceMap.ui32Flags = 0x0;
164
165#if defined(NO_HARDWARE)
166 /*
167 * For no hardware, allocate some contiguous memory for the
168 * register block.
169 */
170
171 /* Registers */
172 gsSGXDeviceMap.ui32RegsSize = SYS_OMAP4430_SGX_REGS_SIZE;
173
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
193
194 OSMemSet(gsSGXRegsCPUVAddr, 0, gsSGXDeviceMap.ui32RegsSize);
195
196 /*
197 device interrupt IRQ
198 Note: no interrupts available on no hardware system
199 */
200 gsSGXDeviceMap.ui32IRQ = 0;
201
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 }
211
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 }
218
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));
223
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
232
233 PVR_TRACE(("SGX register size: %d",gsSGXDeviceMap.ui32RegsSize));
234
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;
241
242 gsSGXDeviceMap.ui32IRQ = SYS_OMAP4430_SGX_IRQ;
243
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);
250
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 }
256
257 /* Indicate the registers are already mapped */
258 gsSGXDeviceMap.pvRegsCpuVBase = gsSGXRegsCPUVAddr;
259 gpvOCPRegsLinAddr = gsSGXRegsCPUVAddr;
260#endif
261#endif /* defined(NO_HARDWARE) */
262
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
270
271 /* add other devices here: */
272
273
274 return PVRSRV_OK;
275}
276
277
278/*!
279******************************************************************************
280
281 @Function SysCreateVersionString
282
283 @Description Read the version string
284
285 @Return IMG_CHAR * : Version string
286
287******************************************************************************/
288static 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;
296
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 }
305
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
312
313#else
314 ui32SGXRevision = 0;
315#endif
316
317 SysAcquireData(&psSysData);
318
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 );
328
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
335
336 if(i32Count == -1)
337 {
338 return IMG_NULL;
339 }
340
341 return aszVersionString;
342}
343
344
345/*!
346******************************************************************************
347
348 @Function SysInitialise
349
350 @Description Initialises kernel services at 'driver load' time
351
352 @Return PVRSRV_ERROR :
353
354******************************************************************************/
355PVRSRV_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));
368
369 gpsSysSpecificData = &gsSysSpecificData;
370 OSMemSet(gpsSysSpecificData, 0, sizeof(SYS_SPECIFIC_DATA));
371
372 gpsSysData->pvSysSpecificData = gpsSysSpecificData;
373
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);
383
384 gpsSysData->ui32NumDevices = SYS_DEVICE_COUNT;
385
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 }
392
393 gpsSysData->psDeviceNodeList = IMG_NULL;
394 gpsSysData->psQueueList = IMG_NULL;
395
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 }
404
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
418
419 /*
420 Setup the Source Clock Divider value
421 */
422 gpsSysSpecificData->ui32SrcClockDiv = 3;
423
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);
438
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);
448
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);
458
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);
473
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;
488
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;
494
495 /* useful pointers */
496 psDevMemoryInfo = &psDeviceNode->sDevMemoryInfo;
497 psDeviceMemoryHeap = psDevMemoryInfo->psDeviceMemoryHeap;
498
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 }
504
505 gpsSGXDevNode = psDeviceNode;
506 gsSysSpecificData.psSGXDevNode = psDeviceNode;
507
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 }
514
515 /* advance to next device */
516 psDeviceNode = psDeviceNode->psNext;
517 }
518
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 */
538
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);
548
549#if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
550 /* SGX defaults to D3 power state */
551 DisableSGXClocks(gpsSysData);
552#endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
553
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) */
572
573
574 return PVRSRV_OK;
575}
576
577#if defined(CONFIG_OMAPLFB)
578int OMAPLFBRegisterPVRDriver(void * pfnFuncTable);
579#endif
580
581/*!
582******************************************************************************
583
584 @Function SysFinalise
585
586 @Description Final part of initialisation at 'driver load' time
587
588 @Return PVRSRV_ERROR :
589
590******************************************************************************/
591PVRSRV_ERROR SysFinalise(IMG_VOID)
592{
593 PVRSRV_ERROR eError = PVRSRV_OK;
594
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 */
603
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);
611
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
637
638#if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
639 /* SGX defaults to D3 power state */
640 DisableSGXClocks(gpsSysData);
641#endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
642
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
650
651 gpsSysSpecificData->bSGXInitComplete = IMG_TRUE;
652
653 return eError;
654}
655
656
657/*!
658******************************************************************************
659
660 @Function SysDeinitialise
661
662 @Description De-initialises kernel services at 'driver unload' time
663
664 @Return PVRSRV_ERROR
665
666******************************************************************************/
667PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData)
668{
669 PVRSRV_ERROR eError;
670
671 PVR_UNREFERENCED_PARAMETER(psSysData);
672
673 if(gpsSysData->pvSOCTimerRegisterKM)
674 {
675 OSUnReservePhys(gpsSysData->pvSOCTimerRegisterKM,
676 4,
677 PVRSRV_HAP_MULTI_PROCESS|PVRSRV_HAP_UNCACHED,
678 gpsSysData->hSOCTimerRegisterOSMemHandle);
679 }
680
681
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
693
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 }
703
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 */
716
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 }
725
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 }
736
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 }
747
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 }
755
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 }
765
766 SysDeinitialiseCommon(gpsSysData);
767
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);
780
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) */
788
789
790 gpsSysSpecificData->ui32SysSpecificData = 0;
791 gpsSysSpecificData->bSGXInitComplete = IMG_FALSE;
792
793 gpsSysData = IMG_NULL;
794
795 return PVRSRV_OK;
796}
797
798
799/*!
800******************************************************************************
801
802 @Function SysGetDeviceMemoryMap
803
804 @Description returns a device address map for the specified device
805
806 @Input eDeviceType - device type
807 @Input ppvDeviceMap - void ptr to receive device specific info.
808
809 @Return PVRSRV_ERROR
810
811******************************************************************************/
812PVRSRV_ERROR SysGetDeviceMemoryMap(PVRSRV_DEVICE_TYPE eDeviceType,
813 IMG_VOID **ppvDeviceMap)
814{
815
816 switch(eDeviceType)
817 {
818 case PVRSRV_DEVICE_TYPE_SGX:
819 {
820 /* just return a pointer to the structure */
821 *ppvDeviceMap = (IMG_VOID*)&gsSGXDeviceMap;
822
823 break;
824 }
825 default:
826 {
827 PVR_DPF((PVR_DBG_ERROR,"SysGetDeviceMemoryMap: unsupported device type"));
828 }
829 }
830 return PVRSRV_OK;
831}
832
833
834/*!
835******************************************************************************
836 @Function SysCpuPAddrToDevPAddr
837
838 @Description Compute a device physical address from a cpu physical
839 address. Relevant when
840
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.
846
847******************************************************************************/
848IMG_DEV_PHYADDR SysCpuPAddrToDevPAddr(PVRSRV_DEVICE_TYPE eDeviceType,
849 IMG_CPU_PHYADDR CpuPAddr)
850{
851 IMG_DEV_PHYADDR DevPAddr;
852
853 PVR_UNREFERENCED_PARAMETER(eDeviceType);
854
855 /* Note: for UMA system we assume DevP == CpuP */
856 DevPAddr.uiAddr = CpuPAddr.uiAddr;
857
858 return DevPAddr;
859}
860
861/*!
862******************************************************************************
863 @Function SysSysPAddrToCpuPAddr
864
865 @Description Compute a cpu physical address from a system physical
866 address.
867
868 @Input sys_paddr - system physical address.
869 @Return cpu physical address.
870
871******************************************************************************/
872IMG_CPU_PHYADDR SysSysPAddrToCpuPAddr (IMG_SYS_PHYADDR sys_paddr)
873{
874 IMG_CPU_PHYADDR cpu_paddr;
875
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}
881
882/*!
883******************************************************************************
884 @Function SysCpuPAddrToSysPAddr
885
886 @Description Compute a system physical address from a cpu physical
887 address.
888
889 @Input cpu_paddr - cpu physical address.
890 @Return device physical address.
891
892******************************************************************************/
893IMG_SYS_PHYADDR SysCpuPAddrToSysPAddr (IMG_CPU_PHYADDR cpu_paddr)
894{
895 IMG_SYS_PHYADDR sys_paddr;
896
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}
902
903
904/*!
905******************************************************************************
906 @Function SysSysPAddrToDevPAddr
907
908 @Description Compute a device physical address from a system physical
909 address.
910
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
915
916 @Return Device physical address.
917
918******************************************************************************/
919IMG_DEV_PHYADDR SysSysPAddrToDevPAddr(PVRSRV_DEVICE_TYPE eDeviceType, IMG_SYS_PHYADDR SysPAddr)
920{
921 IMG_DEV_PHYADDR DevPAddr;
922
923 PVR_UNREFERENCED_PARAMETER(eDeviceType);
924
925 /* Note: for UMA system we assume DevP == CpuP */
926 DevPAddr.uiAddr = SysPAddr.uiAddr;
927
928 return DevPAddr;
929}
930
931
932/*!
933******************************************************************************
934 @Function SysDevPAddrToSysPAddr
935
936 @Description Compute a device physical address from a system physical
937 address.
938
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
943
944 @Return System physical address.
945
946******************************************************************************/
947IMG_SYS_PHYADDR SysDevPAddrToSysPAddr(PVRSRV_DEVICE_TYPE eDeviceType, IMG_DEV_PHYADDR DevPAddr)
948{
949 IMG_SYS_PHYADDR SysPAddr;
950
951 PVR_UNREFERENCED_PARAMETER(eDeviceType);
952
953 /* Note: for UMA system we assume DevP == SysP */
954 SysPAddr.uiAddr = DevPAddr.uiAddr;
955
956 return SysPAddr;
957}
958
959
960/*****************************************************************************
961 @Function SysRegisterExternalDevice
962
963 @Description Called when a 3rd party device registers with services
964
965 @Input psDeviceNode - the new device node.
966
967 @Return IMG_VOID
968*****************************************************************************/
969IMG_VOID SysRegisterExternalDevice(PVRSRV_DEVICE_NODE *psDeviceNode)
970{
971 PVR_UNREFERENCED_PARAMETER(psDeviceNode);
972}
973
974
975/*****************************************************************************
976 @Function SysRemoveExternalDevice
977
978 @Description Called when a 3rd party device unregisters from services
979
980 @Input psDeviceNode - the device node being removed.
981
982 @Return IMG_VOID
983*****************************************************************************/
984IMG_VOID SysRemoveExternalDevice(PVRSRV_DEVICE_NODE *psDeviceNode)
985{
986 PVR_UNREFERENCED_PARAMETER(psDeviceNode);
987}
988
989/*!
990******************************************************************************
991 @Function SysGetInterruptSource
992
993 @Description Returns System specific information about the device(s) that
994 generated the interrupt in the system
995
996 @Input psSysData
997 @Input psDeviceNode
998
999 @Return System specific information indicating which device(s)
1000 generated the interrupt
1001
1002******************************************************************************/
1003IMG_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}
1015
1016
1017/*!
1018******************************************************************************
1019 @Function SysClearInterrupts
1020
1021 @Description Clears specified system interrupts
1022
1023 @Input psSysData
1024 @Input ui32ClearBits
1025
1026 @Return IMG_VOID
1027
1028******************************************************************************/
1029IMG_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}
1041
1042#if defined(SGX_OCP_NO_INT_BYPASS)
1043/*!
1044******************************************************************************
1045 @Function SysEnableSGXInterrupts
1046
1047 @Description Enables SGX interrupts
1048
1049 @Input psSysData
1050
1051 @Return IMG_VOID
1052
1053******************************************************************************/
1054IMG_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}
1064
1065/*!
1066******************************************************************************
1067 @Function SysDisableSGXInterrupts
1068
1069 @Description Disables SGX interrupts
1070
1071 @Input psSysData
1072
1073 @Return IMG_VOID
1074
1075******************************************************************************/
1076IMG_VOID SysDisableSGXInterrupts(SYS_DATA *psSysData)
1077{
1078 SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *)psSysData->pvSysSpecificData;
1079
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) */
1087
1088/*!
1089******************************************************************************
1090
1091 @Function SysSystemPrePowerState
1092
1093 @Description Perform system-level processing required before a power transition
1094
1095 @Input eNewPowerState :
1096
1097 @Return PVRSRV_ERROR
1098
1099******************************************************************************/
1100PVRSRV_ERROR SysSystemPrePowerState(PVRSRV_SYS_POWER_STATE eNewPowerState)
1101{
1102 PVRSRV_ERROR eError = PVRSRV_OK;
1103
1104 if (eNewPowerState == PVRSRV_SYS_POWER_STATE_D3)
1105 {
1106 PVR_TRACE(("SysSystemPrePowerState: Entering state D3"));
1107
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
1130
1131 if (SYS_SPECIFIC_DATA_TEST(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS))
1132 {
1133 DisableSystemClocks(gpsSysData);
1134
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 }
1139
1140 return eError;
1141}
1142
1143
1144/*!
1145******************************************************************************
1146
1147 @Function SysSystemPostPowerState
1148
1149 @Description Perform system-level processing required after a power transition
1150
1151 @Input eNewPowerState :
1152
1153 @Return PVRSRV_ERROR
1154
1155******************************************************************************/
1156PVRSRV_ERROR SysSystemPostPowerState(PVRSRV_SYS_POWER_STATE eNewPowerState)
1157{
1158 PVRSRV_ERROR eError = PVRSRV_OK;
1159
1160 if (eNewPowerState == PVRSRV_SYS_POWER_STATE_D0)
1161 {
1162 PVR_TRACE(("SysSystemPostPowerState: Entering state D0"));
1163
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 }
1175
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
1182
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}
1202
1203
1204/*!
1205******************************************************************************
1206
1207 @Function SysDevicePrePowerState
1208
1209 @Description Perform system level processing required before a device power
1210 transition
1211
1212 @Input ui32DeviceIndex :
1213 @Input eNewPowerState :
1214 @Input eCurrentPowerState :
1215
1216 @Return PVRSRV_ERROR
1217
1218******************************************************************************/
1219PVRSRV_ERROR SysDevicePrePowerState(IMG_UINT32 ui32DeviceIndex,
1220 PVRSRV_DEV_POWER_STATE eNewPowerState,
1221 PVRSRV_DEV_POWER_STATE eCurrentPowerState)
1222{
1223 PVR_UNREFERENCED_PARAMETER(eCurrentPowerState);
1224
1225 if (ui32DeviceIndex != gui32SGXDeviceID)
1226 {
1227 return PVRSRV_OK;
1228 }
1229
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}
1241
1242
1243/*!
1244******************************************************************************
1245
1246 @Function SysDevicePostPowerState
1247
1248 @Description Perform system level processing required after a device power
1249 transition
1250
1251 @Input ui32DeviceIndex :
1252 @Input eNewPowerState :
1253 @Input eCurrentPowerState :
1254
1255 @Return PVRSRV_ERROR
1256
1257******************************************************************************/
1258PVRSRV_ERROR SysDevicePostPowerState(IMG_UINT32 ui32DeviceIndex,
1259 PVRSRV_DEV_POWER_STATE eNewPowerState,
1260 PVRSRV_DEV_POWER_STATE eCurrentPowerState)
1261{
1262 PVRSRV_ERROR eError = PVRSRV_OK;
1263
1264 PVR_UNREFERENCED_PARAMETER(eNewPowerState);
1265
1266 if (ui32DeviceIndex != gui32SGXDeviceID)
1267 {
1268 return eError;
1269 }
1270
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 */
1280
1281 return eError;
1282}
1283
1284IMG_VOID SysLockSystemSuspend(IMG_VOID)
1285{
1286#if defined(CONFIG_HAS_WAKELOCK)
1287 wake_lock(&gpsSysSpecificData->wake_lock);
1288#endif
1289}
1290
1291IMG_VOID SysUnlockSystemSuspend(IMG_VOID)
1292{
1293#if defined(CONFIG_HAS_WAKELOCK)
1294 wake_unlock(&gpsSysSpecificData->wake_lock);
1295#endif
1296}
1297
1298/*****************************************************************************
1299 @Function SysOEMFunction
1300
1301 @Description marshalling function for custom OEM functions
1302
1303 @Input ui32ID - function ID
1304 @Input pvIn - in data
1305 @Output pvOut - out data
1306
1307 @Return PVRSRV_ERROR
1308*****************************************************************************/
1309PVRSRV_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);
1320
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 }
1328
1329 return PVRSRV_ERROR_INVALID_PARAMS;
1330}
1331/******************************************************************************
1332 End of file (sysconfig.c)
1333******************************************************************************/
diff --git a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysconfig.h b/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysconfig.h
deleted file mode 100644
index 64f3187..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysconfig.h
+++ /dev/null
@@ -1,110 +0,0 @@
1/*************************************************************************/ /*!
2@Title System Description Header
3@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4@Description This header provides system-specific declarations and macros
5@License Dual MIT/GPLv2
6
7The contents of this file are subject to the MIT license as set out below.
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19Alternatively, the contents of this file may be used under the terms of
20the GNU General Public License Version 2 ("GPL") in which case the provisions
21of GPL are applicable instead of those above.
22
23If you wish to allow use of your version of this file only under the terms of
24GPL, and not to allow others to use your version of this file under the terms
25of the MIT license, indicate your decision by deleting the provisions above
26and replace them with the notice and other provisions required by GPL as set
27out in the file called "GPL-COPYING" included in this distribution. If you do
28not delete the provisions above, a recipient may use your version of this file
29under the terms of either the MIT license or GPL.
30
31This License is also included in this distribution in the file called
32"MIT-COPYING".
33
34EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
35PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
38COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41*/ /**************************************************************************/
42
43#if !defined(__SOCCONFIG_H__)
44#define __SOCCONFIG_H__
45
46#define VS_PRODUCT_NAME "OMAP4"
47
48#if defined(SGX540) && (SGX_CORE_REV == 120)
49#define SYS_SGX_CLOCK_SPEED 307200000
50#else
51#define SYS_SGX_CLOCK_SPEED 304742400
52#endif
53
54#define SYS_SGX_HWRECOVERY_TIMEOUT_FREQ (100) // 10ms (100hz)
55#define SYS_SGX_PDS_TIMER_FREQ (1000) // 1ms (1000hz)
56
57/* Allow the AP latency to be overridden in the build config */
58#if !defined(SYS_SGX_ACTIVE_POWER_LATENCY_MS)
59#define SYS_SGX_ACTIVE_POWER_LATENCY_MS (2)
60#endif
61
62
63#define SYS_OMAP4430_SGX_REGS_SYS_PHYS_BASE 0x56000000
64#define SYS_OMAP4430_SGX_REGS_SIZE 0xFFFF
65
66#define SYS_OMAP4430_SGX_IRQ 53 /* OMAP4 IRQ's are offset by 32 */
67
68#define SYS_OMAP4430_DSS_REGS_SYS_PHYS_BASE 0x58000000
69#define SYS_OMAP4430_DSS_REGS_SIZE 0x7000
70
71#define SYS_OMAP4430_DSS_HDMI_INTERRUPT_STATUS_REG 0x6028
72#define SYS_OMAP4430_DSS_HDMI_INTERRUPT_ENABLE_REG 0x602c
73
74#define SYS_OMAP4430_DSS_HDMI_INTERRUPT_VSYNC_ENABLE_MASK 0x10000
75#define SYS_OMAP4430_DSS_HDMI_INTERRUPT_VSYNC_STATUS_MASK 0x10000
76
77#define SYS_OMAP4430_DSS_LCD_INTERRUPT_STATUS_REG 0x1018
78#define SYS_OMAP4430_DSS_LCD_INTERRUPT_ENABLE_REG 0x101c
79
80#define SYS_OMAP4430_DSS_LCD_INTERRUPT_VSYNC_ENABLE_MASK 0x40002
81#define SYS_OMAP4430_DSS_LCD_INTERRUPT_VSYNC_STATUS_MASK 0x40002
82
83
84#define SYS_OMAP4430_GP11TIMER_ENABLE_SYS_PHYS_BASE 0x48088038
85#define SYS_OMAP4430_GP11TIMER_REGS_SYS_PHYS_BASE 0x4808803C
86#define SYS_OMAP4430_GP11TIMER_TSICR_SYS_PHYS_BASE 0x48088054
87
88/* Interrupt bits */
89#define DEVICE_SGX_INTERRUPT (1<<0)
90#define DEVICE_MSVDX_INTERRUPT (1<<1)
91#define DEVICE_DISP_INTERRUPT (1<<2)
92
93#if defined(__linux__)
94/*
95 * Recent OMAP4 kernels register SGX as platform device "omap_gpu".
96 * This device must be used with the Linux power management calls
97 * in sysutils_linux.c, in order for SGX to be powered on.
98 */
99#if defined(PVR_LDM_PLATFORM_PRE_REGISTERED_DEV)
100#define SYS_SGX_DEV_NAME PVR_LDM_PLATFORM_PRE_REGISTERED_DEV
101#else
102#define SYS_SGX_DEV_NAME "omap_gpu"
103#endif /* defined(PVR_LDM_PLATFORM_PRE_REGISTERED_DEV) */
104#endif /* defined(__linux__) */
105
106/*****************************************************************************
107 * system specific data structures
108 *****************************************************************************/
109
110#endif /* __SYSCONFIG_H__ */
diff --git a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysinfo.h b/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysinfo.h
deleted file mode 100644
index 70ae148..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysinfo.h
+++ /dev/null
@@ -1,64 +0,0 @@
1/*************************************************************************/ /*!
2@Title System Description Header
3@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4@Description This header provides system-specific declarations and macros
5@License Dual MIT/GPLv2
6
7The contents of this file are subject to the MIT license as set out below.
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19Alternatively, the contents of this file may be used under the terms of
20the GNU General Public License Version 2 ("GPL") in which case the provisions
21of GPL are applicable instead of those above.
22
23If you wish to allow use of your version of this file only under the terms of
24GPL, and not to allow others to use your version of this file under the terms
25of the MIT license, indicate your decision by deleting the provisions above
26and replace them with the notice and other provisions required by GPL as set
27out in the file called "GPL-COPYING" included in this distribution. If you do
28not delete the provisions above, a recipient may use your version of this file
29under the terms of either the MIT license or GPL.
30
31This License is also included in this distribution in the file called
32"MIT-COPYING".
33
34EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
35PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
38COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41*/ /**************************************************************************/
42
43#if !defined(__SYSINFO_H__)
44#define __SYSINFO_H__
45
46/*!< System specific poll/timeout details */
47#if defined(PVR_LINUX_USING_WORKQUEUES)
48/*
49 * The workqueue based 3rd party display driver may be blocked for up
50 * to 500ms waiting for a vsync when the screen goes blank, so we
51 * need to wait longer for the hardware if a flush of the swap chain is
52 * required.
53 */
54#define MAX_HW_TIME_US (1000000)
55#define WAIT_TRY_COUNT (20000)
56#else
57#define MAX_HW_TIME_US (500000)
58#define WAIT_TRY_COUNT (10000)
59#endif
60
61
62#define SYS_DEVICE_COUNT 15 /* SGX, DISPLAYCLASS (external), BUFFERCLASS (external) */
63
64#endif /* __SYSINFO_H__ */
diff --git a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/syslocal.h b/jacinto6/sgx_src/eurasia_km/services4/system/omap4/syslocal.h
deleted file mode 100644
index da1bade..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/syslocal.h
+++ /dev/null
@@ -1,267 +0,0 @@
1/*************************************************************************/ /*!
2@Title Local system definitions
3@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4@Description This header provides local system declarations and macros
5@License Dual MIT/GPLv2
6
7The contents of this file are subject to the MIT license as set out below.
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19Alternatively, the contents of this file may be used under the terms of
20the GNU General Public License Version 2 ("GPL") in which case the provisions
21of GPL are applicable instead of those above.
22
23If you wish to allow use of your version of this file only under the terms of
24GPL, and not to allow others to use your version of this file under the terms
25of the MIT license, indicate your decision by deleting the provisions above
26and replace them with the notice and other provisions required by GPL as set
27out in the file called "GPL-COPYING" included in this distribution. If you do
28not delete the provisions above, a recipient may use your version of this file
29under the terms of either the MIT license or GPL.
30
31This License is also included in this distribution in the file called
32"MIT-COPYING".
33
34EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
35PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
38COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41*/ /**************************************************************************/
42
43#if !defined(__SYSLOCAL_H__)
44#define __SYSLOCAL_H__
45
46#if defined(__linux__)
47
48#include <linux/version.h>
49#include <linux/clk.h>
50#if defined(PVR_LINUX_USING_WORKQUEUES)
51#include <linux/mutex.h>
52#else
53#include <linux/spinlock.h>
54#endif
55#include <asm/atomic.h>
56
57#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26))
58#include <linux/semaphore.h>
59#include <linux/resource.h>
60#else /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)) */
61#include <asm/semaphore.h>
62#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22))
63#include <asm/arch/resource.h>
64#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22)) */
65#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)) */
66
67
68#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
69#if !defined(LDM_PLATFORM)
70#error "LDM_PLATFORM must be set"
71#endif
72#define PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO
73#include <linux/platform_device.h>
74#endif
75
76#if ((defined(DEBUG) || defined(TIMING)) && \
77 (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,34))) && \
78 !defined(PVR_NO_OMAP_TIMER)
79/*
80 * We need to explicitly enable the GPTIMER11 clocks, or we'll get an
81 * abort when we try to access the timer registers.
82 */
83#define PVR_OMAP4_TIMING_PRCM
84#endif
85
86#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
87#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
88#include <plat/gpu.h>
89#endif
90#if !defined(PVR_NO_OMAP_TIMER)
91#define PVR_OMAP_USE_DM_TIMER_API
92#include <plat/dmtimer.h>
93#endif
94#endif
95
96#if defined(CONFIG_HAS_WAKELOCK)
97#include <linux/wakelock.h>
98#endif
99
100#if !defined(PVR_NO_OMAP_TIMER)
101#define PVR_OMAP_TIMER_BASE_IN_SYS_SPEC_DATA
102#endif
103#endif /* defined(__linux__) */
104
105#if !defined(NO_HARDWARE) && \
106 defined(SYS_USING_INTERRUPTS)
107#define SGX_OCP_REGS_ENABLED
108#endif
109
110#if defined(__linux__)
111#if defined(SGX_OCP_REGS_ENABLED)
112#define SGX_OCP_NO_INT_BYPASS
113#endif
114#endif
115
116#if defined (__cplusplus)
117extern "C" {
118#endif
119
120/*****************************************************************************
121 * system specific data structures
122 *****************************************************************************/
123
124/*****************************************************************************
125 * system specific function prototypes
126 *****************************************************************************/
127
128IMG_VOID DisableSystemClocks(SYS_DATA *psSysData);
129PVRSRV_ERROR EnableSystemClocks(SYS_DATA *psSysData);
130
131IMG_VOID DisableSGXClocks(SYS_DATA *psSysData);
132PVRSRV_ERROR EnableSGXClocks(SYS_DATA *psSysData);
133
134/*
135 * Various flags to indicate what has been initialised, and what
136 * has been temporarily deinitialised for power management purposes.
137 */
138#define SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS 0x00000001
139#define SYS_SPECIFIC_DATA_ENABLE_LISR 0x00000002
140#define SYS_SPECIFIC_DATA_ENABLE_MISR 0x00000004
141#define SYS_SPECIFIC_DATA_ENABLE_ENVDATA 0x00000008
142#define SYS_SPECIFIC_DATA_ENABLE_LOCDEV 0x00000010
143#define SYS_SPECIFIC_DATA_ENABLE_REGDEV 0x00000020
144#define SYS_SPECIFIC_DATA_ENABLE_PDUMPINIT 0x00000040
145#define SYS_SPECIFIC_DATA_ENABLE_INITDEV 0x00000080
146#define SYS_SPECIFIC_DATA_ENABLE_LOCATEDEV 0x00000100
147
148#define SYS_SPECIFIC_DATA_PM_UNINSTALL_LISR 0x00000200
149#define SYS_SPECIFIC_DATA_PM_DISABLE_SYSCLOCKS 0x00000400
150#define SYS_SPECIFIC_DATA_ENABLE_OCPREGS 0x00000800
151#define SYS_SPECIFIC_DATA_ENABLE_PM_RUNTIME 0x00001000
152#define SYS_SPECIFIC_DATA_IRQ_ENABLED 0x00002000
153#define SYS_SPECIFIC_DATA_DVFS_INIT 0x00004000
154
155#define SYS_SPECIFIC_DATA_SET(psSysSpecData, flag) ((IMG_VOID)((psSysSpecData)->ui32SysSpecificData |= (flag)))
156
157#define SYS_SPECIFIC_DATA_CLEAR(psSysSpecData, flag) ((IMG_VOID)((psSysSpecData)->ui32SysSpecificData &= ~(flag)))
158
159#define SYS_SPECIFIC_DATA_TEST(psSysSpecData, flag) (((psSysSpecData)->ui32SysSpecificData & (flag)) != 0)
160
161typedef struct _SYS_SPECIFIC_DATA_TAG_
162{
163 IMG_UINT32 ui32SysSpecificData;
164 PVRSRV_DEVICE_NODE *psSGXDevNode;
165 IMG_BOOL bSGXInitComplete;
166#if defined(PVR_OMAP_TIMER_BASE_IN_SYS_SPEC_DATA)
167 IMG_CPU_PHYADDR sTimerRegPhysBase;
168#endif
169#if !defined(__linux__)
170 IMG_BOOL bSGXClocksEnabled;
171#endif
172 IMG_UINT32 ui32SrcClockDiv;
173#if defined(__linux__)
174 IMG_BOOL bSysClocksOneTimeInit;
175 atomic_t sSGXClocksEnabled;
176#if defined(PVR_LINUX_USING_WORKQUEUES)
177 struct mutex sPowerLock;
178#else
179 IMG_BOOL bConstraintNotificationsEnabled;
180 spinlock_t sPowerLock;
181 atomic_t sPowerLockCPU;
182 spinlock_t sNotifyLock;
183 atomic_t sNotifyLockCPU;
184 IMG_BOOL bCallVDD2PostFunc;
185#endif
186#if defined(DEBUG) || defined(TIMING)
187 struct clk *psGPT11_FCK;
188 struct clk *psGPT11_ICK;
189#endif
190#if defined(PVR_OMAP_USE_DM_TIMER_API)
191 struct omap_dm_timer *psGPTimer;
192#endif
193#if defined(CONFIG_HAS_WAKELOCK)
194 struct wake_lock wake_lock;
195#endif /* CONFIG_HAS_WAKELOCK */
196#endif /* defined(__linux__) */
197} SYS_SPECIFIC_DATA;
198
199extern SYS_SPECIFIC_DATA *gpsSysSpecificData;
200
201#if defined(SGX_OCP_REGS_ENABLED) && defined(SGX_OCP_NO_INT_BYPASS)
202IMG_VOID SysEnableSGXInterrupts(SYS_DATA* psSysData);
203IMG_VOID SysDisableSGXInterrupts(SYS_DATA* psSysData);
204#else
205#define SysEnableSGXInterrupts(psSysData)
206#define SysDisableSGXInterrupts(psSysData)
207#endif
208
209#if defined(SYS_CUSTOM_POWERLOCK_WRAP)
210IMG_BOOL WrapSystemPowerChange(SYS_SPECIFIC_DATA *psSysSpecData);
211IMG_VOID UnwrapSystemPowerChange(SYS_SPECIFIC_DATA *psSysSpecData);
212#endif
213
214#if defined(__linux__)
215
216PVRSRV_ERROR SysPMRuntimeRegister(SYS_SPECIFIC_DATA *psSysSpecificData);
217PVRSRV_ERROR SysPMRuntimeUnregister(SYS_SPECIFIC_DATA *psSysSpecificData);
218
219PVRSRV_ERROR SysDvfsInitialize(SYS_SPECIFIC_DATA *psSysSpecificData);
220PVRSRV_ERROR SysDvfsDeinitialize(SYS_SPECIFIC_DATA *psSysSpecificData);
221int pvr_access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
222
223#else /* defined(__linux__) */
224
225#ifdef INLINE_IS_PRAGMA
226#pragma inline(SysPMRuntimeRegister)
227#endif
228static INLINE PVRSRV_ERROR SysPMRuntimeRegister(void)
229{
230 return PVRSRV_OK;
231}
232
233#ifdef INLINE_IS_PRAGMA
234#pragma inline(SysPMRuntimeUnregister)
235#endif
236static INLINE PVRSRV_ERROR SysPMRuntimeUnregister(void)
237{
238 return PVRSRV_OK;
239}
240
241#ifdef INLINE_IS_PRAGMA
242#pragma inline(SysDvfsInitialize)
243#endif
244static INLINE PVRSRV_ERROR SysDvfsInitialize(void)
245{
246 return PVRSRV_OK;
247}
248
249#ifdef INLINE_IS_PRAGMA
250#pragma inline(SysDvfsDeinitialize)
251#endif
252static INLINE PVRSRV_ERROR SysDvfsDeinitialize(void)
253{
254 return PVRSRV_OK;
255}
256
257#define pvr_access_process_vm(tsk, addr, buf, len, write) -1
258
259#endif /* defined(__linux__) */
260
261#if defined(__cplusplus)
262}
263#endif
264
265#endif /* __SYSLOCAL_H__ */
266
267
diff --git a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysutils.c b/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysutils.c
deleted file mode 100644
index fef97c2..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysutils.c
+++ /dev/null
@@ -1,59 +0,0 @@
1/*************************************************************************/ /*!
2@Title Shared (User/kernel) and System dependent utilities
3@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4@Description Provides system-specific functions
5@License Dual MIT/GPLv2
6
7The contents of this file are subject to the MIT license as set out below.
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19Alternatively, the contents of this file may be used under the terms of
20the GNU General Public License Version 2 ("GPL") in which case the provisions
21of GPL are applicable instead of those above.
22
23If you wish to allow use of your version of this file only under the terms of
24GPL, and not to allow others to use your version of this file under the terms
25of the MIT license, indicate your decision by deleting the provisions above
26and replace them with the notice and other provisions required by GPL as set
27out in the file called "GPL-COPYING" included in this distribution. If you do
28not delete the provisions above, a recipient may use your version of this file
29under the terms of either the MIT license or GPL.
30
31This License is also included in this distribution in the file called
32"MIT-COPYING".
33
34EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
35PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
38COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41*/ /**************************************************************************/
42
43/* Pull in the correct system dependent sysutils source */
44
45#if defined(__linux__)
46#include "sysutils_linux.c"
47#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK)
48#include "sgxfreq.c"
49#include "sgxfreq_onoff.c"
50#include "sgxfreq_activeidle.c"
51#include "sgxfreq_on3demand.c"
52#include "sgxfreq_userspace.c"
53#if (defined(CONFIG_THERMAL) || defined(CONFIG_THERMAL_FRAMEWORK))
54#include "sgxfreq_cool.c"
55#endif
56#endif
57#endif
58
59
diff --git a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysutils_linux.c b/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysutils_linux.c
deleted file mode 100644
index 358e9f8..0000000
--- a/jacinto6/sgx_src/eurasia_km/services4/system/omap4/sysutils_linux.c
+++ /dev/null
@@ -1,751 +0,0 @@
1/*************************************************************************/ /*!
2@Title System dependent utilities
3@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4@Description Provides system-specific functions
5@License Dual MIT/GPLv2
6
7The contents of this file are subject to the MIT license as set out below.
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19Alternatively, the contents of this file may be used under the terms of
20the GNU General Public License Version 2 ("GPL") in which case the provisions
21of GPL are applicable instead of those above.
22
23If you wish to allow use of your version of this file only under the terms of
24GPL, and not to allow others to use your version of this file under the terms
25of the MIT license, indicate your decision by deleting the provisions above
26and replace them with the notice and other provisions required by GPL as set
27out in the file called "GPL-COPYING" included in this distribution. If you do
28not delete the provisions above, a recipient may use your version of this file
29under the terms of either the MIT license or GPL.
30
31This License is also included in this distribution in the file called
32"MIT-COPYING".
33
34EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
35PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
38COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41*/ /**************************************************************************/
42#include <linux/version.h>
43#include <linux/clk.h>
44#include <linux/err.h>
45#include <linux/hardirq.h>
46#include <linux/mutex.h>
47#include <linux/slab.h>
48
49#include "sgxdefs.h"
50#include "services_headers.h"
51#include "sysinfo.h"
52#include "sgxapi_km.h"
53#include "sysconfig.h"
54#include "sgxinfokm.h"
55#include "syslocal.h"
56
57#include <linux/platform_device.h>
58#include <linux/pm_runtime.h>
59
60#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK)
61#include "sgxfreq.h"
62#endif
63
64#if defined(SUPPORT_DRI_DRM_PLUGIN)
65#include <drm/drmP.h>
66#include <drm/drm.h>
67
68#include <linux/omap_gpu.h>
69
70#include "pvr_drm.h"
71#endif
72
73#if defined(CONFIG_OMAP4_DPLL_CASCADING)
74#include <mach/omap4-common.h>
75#endif
76
77#define ONE_MHZ 1000000
78#define HZ_TO_MHZ(m) ((m) / ONE_MHZ)
79
80#if defined(SUPPORT_OMAP3430_SGXFCLK_96M)
81#define SGX_PARENT_CLOCK "cm_96m_fck"
82#else
83#define SGX_PARENT_CLOCK "core_ck"
84#endif
85
86#if defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI)
87extern struct platform_device *gpsPVRLDMDev;
88#endif
89
90static PVRSRV_ERROR PowerLockWrap(SYS_SPECIFIC_DATA *psSysSpecData, IMG_BOOL bTryLock)
91{
92 if (!in_interrupt())
93 {
94 if (bTryLock)
95 {
96 int locked = mutex_trylock(&psSysSpecData->sPowerLock);
97 if (locked == 0)
98 {
99 return PVRSRV_ERROR_RETRY;
100 }
101 }
102 else
103 {
104 mutex_lock(&psSysSpecData->sPowerLock);
105 }
106 }
107
108 return PVRSRV_OK;
109}
110
111static IMG_VOID PowerLockUnwrap(SYS_SPECIFIC_DATA *psSysSpecData)
112{
113 if (!in_interrupt())
114 {
115 mutex_unlock(&psSysSpecData->sPowerLock);
116 }
117}
118
119PVRSRV_ERROR SysPowerLockWrap(IMG_BOOL bTryLock)
120{
121 SYS_DATA *psSysData;
122
123 SysAcquireData(&psSysData);
124
125 return PowerLockWrap(psSysData->pvSysSpecificData, bTryLock);
126}
127
128IMG_VOID SysPowerLockUnwrap(IMG_VOID)
129{
130 SYS_DATA *psSysData;
131
132 SysAcquireData(&psSysData);
133
134 PowerLockUnwrap(psSysData->pvSysSpecificData);
135}
136
137/*
138 * This function should be called to unwrap the Services power lock, prior
139 * to calling any function that might sleep.
140 * This function shouldn't be called prior to calling EnableSystemClocks
141 * or DisableSystemClocks, as those functions perform their own power lock
142 * unwrapping.
143 * If the function returns IMG_TRUE, UnwrapSystemPowerChange must be
144 * called to rewrap the power lock, prior to returning to Services.
145 */
146IMG_BOOL WrapSystemPowerChange(SYS_SPECIFIC_DATA *psSysSpecData)
147{
148 return IMG_TRUE;
149}
150
151IMG_VOID UnwrapSystemPowerChange(SYS_SPECIFIC_DATA *psSysSpecData)
152{
153}
154
155/*
156 * Return SGX timining information to caller.
157 */
158IMG_VOID SysGetSGXTimingInformation(SGX_TIMING_INFORMATION *psTimingInfo)
159{
160#if !defined(NO_HARDWARE)
161 PVR_ASSERT(atomic_read(&gpsSysSpecificData->sSGXClocksEnabled) != 0);
162#endif
163#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK)
164 /*
165 * The core SGX driver and ukernel code expects SGX frequency
166 * changes to occur only just prior to SGX initialization. We
167 * don't wish to constrain the DVFS implementation as such. So
168 * we let these components believe that frequency setting is
169 * always at maximum. This produces safe values for derived
170 * parameters such as APM and HWR timeouts.
171 */
172 psTimingInfo->ui32CoreClockSpeed = (IMG_UINT32)sgxfreq_get_freq_max();
173#else /* defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) */
174 psTimingInfo->ui32CoreClockSpeed = SYS_SGX_CLOCK_SPEED;
175#endif
176 psTimingInfo->ui32HWRecoveryFreq = SYS_SGX_HWRECOVERY_TIMEOUT_FREQ;
177 psTimingInfo->ui32uKernelFreq = SYS_SGX_PDS_TIMER_FREQ;
178#if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT)
179 psTimingInfo->bEnableActivePM = IMG_TRUE;
180#else
181 psTimingInfo->bEnableActivePM = IMG_FALSE;
182#endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */
183 psTimingInfo->ui32ActivePowManLatencyms = SYS_SGX_ACTIVE_POWER_LATENCY_MS;
184}
185
186/*!
187******************************************************************************
188
189 @Function EnableSGXClocks
190
191 @Description Enable SGX clocks
192
193 @Return PVRSRV_ERROR
194
195******************************************************************************/
196PVRSRV_ERROR EnableSGXClocks(SYS_DATA *psSysData)
197{
198#if !defined(NO_HARDWARE)
199 SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData;
200
201 /* SGX clocks already enabled? */
202 if (atomic_read(&psSysSpecData->sSGXClocksEnabled) != 0)
203 {
204 return PVRSRV_OK;
205 }
206
207 PVR_DPF((PVR_DBG_MESSAGE, "EnableSGXClocks: Enabling SGX Clocks"));
208
209#if defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI)
210 {
211 int res;
212
213#if defined(CONFIG_OMAP4_DPLL_CASCADING)
214 if (omap4_dpll_cascading_blocker_hold(&gpsPVRLDMDev->dev))
215 {
216 PVR_DPF((PVR_DBG_WARNING, "EnableSGXClocks: "
217 "omap4_dpll_cascading_blocker_hold failed"));
218 }
219#endif
220 /*
221 * pm_runtime_get_sync returns 1 after the module has
222 * been reloaded.
223 */
224 res = pm_runtime_get_sync(&gpsPVRLDMDev->dev);
225 if (res < 0)
226 {
227 PVR_DPF((PVR_DBG_ERROR, "EnableSGXClocks: pm_runtime_get_sync failed (%d)", -res));
228 return PVRSRV_ERROR_UNABLE_TO_ENABLE_CLOCK;
229 }
230 }
231#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK)
232 sgxfreq_notif_sgx_clk_on();
233#endif /* defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) */
234#endif /* defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI) */
235
236 SysEnableSGXInterrupts(psSysData);
237
238 /* Indicate that the SGX clocks are enabled */
239 atomic_set(&psSysSpecData->sSGXClocksEnabled, 1);
240
241#else /* !defined(NO_HARDWARE) */
242 PVR_UNREFERENCED_PARAMETER(psSysData);
243#endif /* !defined(NO_HARDWARE) */
244 return PVRSRV_OK;
245}
246
247
248/*!
249******************************************************************************
250
251 @Function DisableSGXClocks
252
253 @Description Disable SGX clocks.
254
255 @Return none
256
257******************************************************************************/
258IMG_VOID DisableSGXClocks(SYS_DATA *psSysData)
259{
260#if !defined(NO_HARDWARE)
261 SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData;
262
263 /* SGX clocks already disabled? */
264 if (atomic_read(&psSysSpecData->sSGXClocksEnabled) == 0)
265 {
266 return;
267 }
268
269 PVR_DPF((PVR_DBG_MESSAGE, "DisableSGXClocks: Disabling SGX Clocks"));
270
271 SysDisableSGXInterrupts(psSysData);
272
273#if defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI)
274 {
275 int res = pm_runtime_put_sync(&gpsPVRLDMDev->dev);
276 if (res < 0)
277 {
278 PVR_DPF((PVR_DBG_ERROR, "DisableSGXClocks: pm_runtime_put_sync failed (%d)", -res));
279 }
280#if defined(CONFIG_OMAP4_DPLL_CASCADING)
281 if (omap4_dpll_cascading_blocker_release(&gpsPVRLDMDev->dev))
282 {
283 PVR_DPF((PVR_DBG_WARNING, "DisableSGXClocks: "
284 "omap4_dpll_cascading_blocker_release failed"));
285 }
286#endif
287 }
288#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK)
289 sgxfreq_notif_sgx_clk_off();
290#endif /* defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) */
291#endif /* defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI) */
292
293 /* Indicate that the SGX clocks are disabled */
294 atomic_set(&psSysSpecData->sSGXClocksEnabled, 0);
295
296#else /* !defined(NO_HARDWARE) */
297 PVR_UNREFERENCED_PARAMETER(psSysData);
298#endif /* !defined(NO_HARDWARE) */
299}
300
301#if (defined(DEBUG) || defined(TIMING)) && !defined(PVR_NO_OMAP_TIMER)
302#if defined(PVR_OMAP_USE_DM_TIMER_API)
303#define GPTIMER_TO_USE 11
304/*!
305******************************************************************************
306
307 @Function AcquireGPTimer
308
309 @Description Acquire a GP timer
310
311 @Return PVRSRV_ERROR
312
313******************************************************************************/
314static PVRSRV_ERROR AcquireGPTimer(SYS_SPECIFIC_DATA *psSysSpecData)
315{
316 PVR_ASSERT(psSysSpecData->psGPTimer == NULL);
317
318 /*
319 * This code could try requesting registers 9, 10, and 11,
320 * stopping at the first succesful request. We'll stick with
321 * 11 for now, as it avoids having to hard code yet more
322 * physical addresses into the code.
323 */
324 psSysSpecData->psGPTimer = omap_dm_timer_request_specific(GPTIMER_TO_USE);
325 if (psSysSpecData->psGPTimer == NULL)
326 {
327
328 PVR_DPF((PVR_DBG_WARNING, "%s: omap_dm_timer_request_specific failed", __FUNCTION__));
329 return PVRSRV_ERROR_CLOCK_REQUEST_FAILED;
330 }
331
332 /* Set timer source to system clock */
333 omap_dm_timer_set_source(psSysSpecData->psGPTimer, OMAP_TIMER_SRC_SYS_CLK);
334 omap_dm_timer_enable(psSysSpecData->psGPTimer);
335
336 /* Set autoreload, and start value of 0 */
337 omap_dm_timer_set_load_start(psSysSpecData->psGPTimer, 1, 0);
338
339 omap_dm_timer_start(psSysSpecData->psGPTimer);
340
341 /*
342 * The DM timer API doesn't have a mechansim for obtaining the
343 * physical address of the counter register.
344 */
345 psSysSpecData->sTimerRegPhysBase.uiAddr = SYS_OMAP4430_GP11TIMER_REGS_SYS_PHYS_BASE;
346
347 return PVRSRV_OK;
348}
349
350/*!
351******************************************************************************
352
353 @Function ReleaseGPTimer
354
355 @Description Release a GP timer
356
357 @Return PVRSRV_ERROR
358
359******************************************************************************/
360static void ReleaseGPTimer(SYS_SPECIFIC_DATA *psSysSpecData)
361{
362 if (psSysSpecData->psGPTimer != NULL)
363 {
364 /* Always returns 0 */
365 (void) omap_dm_timer_stop(psSysSpecData->psGPTimer);
366
367 omap_dm_timer_disable(psSysSpecData->psGPTimer);
368
369 omap_dm_timer_free(psSysSpecData->psGPTimer);
370
371 psSysSpecData->sTimerRegPhysBase.uiAddr = 0;
372
373 psSysSpecData->psGPTimer = NULL;
374 }
375
376}
377#else /* PVR_OMAP_USE_DM_TIMER_API */
378/*!
379******************************************************************************
380
381 @Function AcquireGPTimer
382
383 @Description Acquire a GP timer
384
385 @Return PVRSRV_ERROR
386
387******************************************************************************/
388static PVRSRV_ERROR AcquireGPTimer(SYS_SPECIFIC_DATA *psSysSpecData)
389{
390#if defined(PVR_OMAP4_TIMING_PRCM)
391 struct clk *psCLK;
392 IMG_INT res;
393 struct clk *sys_ck;
394 IMG_INT rate;
395#endif
396 PVRSRV_ERROR eError;
397
398 IMG_CPU_PHYADDR sTimerRegPhysBase;
399 IMG_HANDLE hTimerEnable;
400 IMG_UINT32 *pui32TimerEnable;
401
402 PVR_ASSERT(psSysSpecData->sTimerRegPhysBase.uiAddr == 0);
403
404#if defined(PVR_OMAP4_TIMING_PRCM)
405 /* assert our dependence on the GPTIMER11 module */
406 psCLK = clk_get(NULL, "gpt11_fck");
407 if (IS_ERR(psCLK))
408 {
409 PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: Couldn't get GPTIMER11 functional clock"));
410 goto ExitError;
411 }
412 psSysSpecData->psGPT11_FCK = psCLK;
413
414 psCLK = clk_get(NULL, "gpt11_ick");
415 if (IS_ERR(psCLK))
416 {
417 PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: Couldn't get GPTIMER11 interface clock"));
418 goto ExitError;
419 }
420 psSysSpecData->psGPT11_ICK = psCLK;
421
422 sys_ck = clk_get(NULL, "sys_clkin_ck");
423 if (IS_ERR(sys_ck))
424 {
425 PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: Couldn't get System clock"));
426 goto ExitError;
427 }
428
429 if(clk_get_parent(psSysSpecData->psGPT11_FCK) != sys_ck)
430 {
431 PVR_TRACE(("Setting GPTIMER11 parent to System Clock"));
432 res = clk_set_parent(psSysSpecData->psGPT11_FCK, sys_ck);
433 if (res < 0)
434 {
435 PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: Couldn't set GPTIMER11 parent clock (%d)", res));
436 goto ExitError;
437 }
438 }
439
440 rate = clk_get_rate(psSysSpecData->psGPT11_FCK);
441 PVR_TRACE(("GPTIMER11 clock is %dMHz", HZ_TO_MHZ(rate)));
442
443 res = clk_enable(psSysSpecData->psGPT11_FCK);
444 if (res < 0)
445 {
446 PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: Couldn't enable GPTIMER11 functional clock (%d)", res));
447 goto ExitError;
448 }
449
450 res = clk_enable(psSysSpecData->psGPT11_ICK);
451 if (res < 0)
452 {
453 PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: Couldn't enable GPTIMER11 interface clock (%d)", res));
454 goto ExitDisableGPT11FCK;
455 }
456#endif /* defined(PVR_OMAP4_TIMING_PRCM) */
457
458 /* Set the timer to non-posted mode */
459 sTimerRegPhysBase.uiAddr = SYS_OMAP4430_GP11TIMER_TSICR_SYS_PHYS_BASE;
460 pui32TimerEnable = OSMapPhysToLin(sTimerRegPhysBase,
461 4,
462 PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED,
463 &hTimerEnable);
464
465 if (pui32TimerEnable == IMG_NULL)
466 {
467 PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: OSMapPhysToLin failed"));
468 goto ExitDisableGPT11ICK;
469 }
470
471 if(!(*pui32TimerEnable & 4))
472 {
473 PVR_TRACE(("Setting GPTIMER11 mode to posted (currently is non-posted)"));
474
475 /* Set posted mode */
476 *pui32TimerEnable |= 4;
477 }
478
479 OSUnMapPhysToLin(pui32TimerEnable,
480 4,
481 PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED,
482 hTimerEnable);
483
484 /* Enable the timer */
485 sTimerRegPhysBase.uiAddr = SYS_OMAP4430_GP11TIMER_ENABLE_SYS_PHYS_BASE;
486 pui32TimerEnable = OSMapPhysToLin(sTimerRegPhysBase,
487 4,
488 PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED,
489 &hTimerEnable);
490
491 if (pui32TimerEnable == IMG_NULL)
492 {
493 PVR_DPF((PVR_DBG_ERROR, "EnableSystemClocks: OSMapPhysToLin failed"));
494 goto ExitDisableGPT11ICK;
495 }
496
497 /* Enable and set autoreload on overflow */
498 *pui32TimerEnable = 3;
499
500 OSUnMapPhysToLin(pui32TimerEnable,
501 4,
502 PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED,
503 hTimerEnable);
504
505 psSysSpecData->sTimerRegPhysBase = sTimerRegPhysBase;
506
507 eError = PVRSRV_OK;
508
509 goto Exit;
510
511ExitDisableGPT11ICK:
512#if defined(PVR_OMAP4_TIMING_PRCM)
513 clk_disable(psSysSpecData->psGPT11_ICK);
514ExitDisableGPT11FCK:
515 clk_disable(psSysSpecData->psGPT11_FCK);
516ExitError:
517#endif /* defined(PVR_OMAP4_TIMING_PRCM) */
518 eError = PVRSRV_ERROR_CLOCK_REQUEST_FAILED;
519Exit:
520 return eError;
521}
522
523/*!
524******************************************************************************
525
526 @Function ReleaseGPTimer
527
528 @Description Release a GP timer
529
530 @Return PVRSRV_ERROR
531
532******************************************************************************/
533static void ReleaseGPTimer(SYS_SPECIFIC_DATA *psSysSpecData)
534{
535 IMG_HANDLE hTimerDisable;
536 IMG_UINT32 *pui32TimerDisable;
537
538 if (psSysSpecData->sTimerRegPhysBase.uiAddr == 0)
539 {
540 return;
541 }
542
543 /* Disable the timer */
544 pui32TimerDisable = OSMapPhysToLin(psSysSpecData->sTimerRegPhysBase,
545 4,
546 PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED,
547 &hTimerDisable);
548
549 if (pui32TimerDisable == IMG_NULL)
550 {
551 PVR_DPF((PVR_DBG_ERROR, "DisableSystemClocks: OSMapPhysToLin failed"));
552 }
553 else
554 {
555 *pui32TimerDisable = 0;
556
557 OSUnMapPhysToLin(pui32TimerDisable,
558 4,
559 PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED,
560 hTimerDisable);
561 }
562
563 psSysSpecData->sTimerRegPhysBase.uiAddr = 0;
564
565#if defined(PVR_OMAP4_TIMING_PRCM)
566 clk_disable(psSysSpecData->psGPT11_ICK);
567
568 clk_disable(psSysSpecData->psGPT11_FCK);
569#endif /* defined(PVR_OMAP4_TIMING_PRCM) */
570}
571#endif /* PVR_OMAP_USE_DM_TIMER_API */
572#else /* (DEBUG || TIMING) && !PVR_NO_OMAP_TIMER */
573static PVRSRV_ERROR AcquireGPTimer(SYS_SPECIFIC_DATA *psSysSpecData)
574{
575 PVR_UNREFERENCED_PARAMETER(psSysSpecData);
576
577 return PVRSRV_OK;
578}
579static void ReleaseGPTimer(SYS_SPECIFIC_DATA *psSysSpecData)
580{
581 PVR_UNREFERENCED_PARAMETER(psSysSpecData);
582}
583#endif /* (DEBUG || TIMING) && !PVR_NO_OMAP_TIMER */
584
585/*!
586******************************************************************************
587
588 @Function EnableSystemClocks
589
590 @Description Setup up the clocks for the graphics device to work.
591
592 @Return PVRSRV_ERROR
593
594******************************************************************************/
595PVRSRV_ERROR EnableSystemClocks(SYS_DATA *psSysData)
596{
597 SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData;
598
599 PVR_TRACE(("EnableSystemClocks: Enabling System Clocks"));
600
601 if (!psSysSpecData->bSysClocksOneTimeInit)
602 {
603 mutex_init(&psSysSpecData->sPowerLock);
604
605 atomic_set(&psSysSpecData->sSGXClocksEnabled, 0);
606
607 psSysSpecData->bSysClocksOneTimeInit = IMG_TRUE;
608 }
609
610 return AcquireGPTimer(psSysSpecData);
611}
612
613/*!
614******************************************************************************
615
616 @Function DisableSystemClocks
617
618 @Description Disable the graphics clocks.
619
620 @Return none
621
622******************************************************************************/
623IMG_VOID DisableSystemClocks(SYS_DATA *psSysData)
624{
625 SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData;
626
627 PVR_TRACE(("DisableSystemClocks: Disabling System Clocks"));
628
629 /*
630 * Always disable the SGX clocks when the system clocks are disabled.
631 * This saves having to make an explicit call to DisableSGXClocks if
632 * active power management is enabled.
633 */
634 DisableSGXClocks(psSysData);
635
636 ReleaseGPTimer(psSysSpecData);
637}
638
639PVRSRV_ERROR SysPMRuntimeRegister(SYS_SPECIFIC_DATA *psSysSpecificData)
640{
641#if defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI)
642 pm_runtime_enable(&gpsPVRLDMDev->dev);
643#endif
644#if defined(CONFIG_HAS_WAKELOCK)
645 wake_lock_init(&psSysSpecificData->wake_lock, WAKE_LOCK_SUSPEND, "pvrsrvkm");
646#endif
647 return PVRSRV_OK;
648}
649
650PVRSRV_ERROR SysPMRuntimeUnregister(SYS_SPECIFIC_DATA *psSysSpecificData)
651{
652#if defined(LDM_PLATFORM) && !defined(PVR_DRI_DRM_NOT_PCI)
653 pm_runtime_disable(&gpsPVRLDMDev->dev);
654#endif
655#if defined(CONFIG_HAS_WAKELOCK)
656 wake_lock_destroy(&psSysSpecificData->wake_lock);
657#endif
658 return PVRSRV_OK;
659}
660
661PVRSRV_ERROR SysDvfsInitialize(SYS_SPECIFIC_DATA *psSysSpecificData)
662{
663 PVR_UNREFERENCED_PARAMETER(psSysSpecificData);
664#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK)
665 if (sgxfreq_init(&gpsPVRLDMDev->dev))
666 return PVRSRV_ERROR_NOT_SUPPORTED;
667#endif /* defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) */
668
669 return PVRSRV_OK;
670}
671
672PVRSRV_ERROR SysDvfsDeinitialize(SYS_SPECIFIC_DATA *psSysSpecificData)
673{
674 PVR_UNREFERENCED_PARAMETER(psSysSpecificData);
675#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK)
676 if (sgxfreq_deinit())
677 return PVRSRV_ERROR_NOT_SUPPORTED;
678#endif /* defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) */
679
680 return PVRSRV_OK;
681}
682
683#if defined(SUPPORT_DRI_DRM_PLUGIN)
684static struct omap_gpu_plugin sOMAPGPUPlugin;
685
686#define SYS_DRM_SET_PLUGIN_FIELD(d, s, f) (d)->f = (s)->f
687int
688SysDRMRegisterPlugin(PVRSRV_DRM_PLUGIN *psDRMPlugin)
689{
690 int iRes;
691
692 SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, name);
693 SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, open);
694 SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, load);
695 SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, unload);
696 SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, release);
697 SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, mmap);
698 SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, ioctls);
699 SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, num_ioctls);
700 SYS_DRM_SET_PLUGIN_FIELD(&sOMAPGPUPlugin, psDRMPlugin, ioctl_start);
701
702 iRes = omap_gpu_register_plugin(&sOMAPGPUPlugin);
703 if (iRes != 0)
704 {
705 PVR_DPF((PVR_DBG_ERROR, "%s: omap_gpu_register_plugin failed (%d)", __FUNCTION__, iRes));
706 }
707
708 return iRes;
709}
710
711void
712SysDRMUnregisterPlugin(PVRSRV_DRM_PLUGIN *psDRMPlugin)
713{
714 int iRes = omap_gpu_unregister_plugin(&sOMAPGPUPlugin);
715 if (iRes != 0)
716 {
717 PVR_DPF((PVR_DBG_ERROR, "%s: omap_gpu_unregister_plugin failed (%d)", __FUNCTION__, iRes));
718 }
719}
720#endif
721
722int pvr_access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
723{
724#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
725 struct gpu_platform_data *pdata;
726 pdata = (struct gpu_platform_data *)gpsPVRLDMDev->dev.platform_data;
727 if(!pdata || !pdata->access_process_vm)
728 return -1;
729 return pdata->access_process_vm(tsk, addr, buf, len, write);
730#else
731 /* FIXME: platform data not supported in 3.8 kernel */
732 return -1;
733#endif
734}
735
736IMG_VOID SysSGXIdleEntered(IMG_VOID)
737{
738#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK)
739 sgxfreq_notif_sgx_idle();
740#endif
741}
742
743IMG_VOID SysSGXCommandPending(IMG_BOOL bSGXIdle)
744{
745#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK)
746 if (bSGXIdle)
747 sgxfreq_notif_sgx_active();
748#else
749 PVR_UNREFERENCED_PARAMETER(bSGXIdle);
750#endif
751}