summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHemant Hariyani2014-05-07 14:55:12 -0500
committerHemant Hariyani2014-05-07 15:09:44 -0500
commit34dceb6b8f0783c045442d904e2bbb1f6bce0686 (patch)
tree2993cc8d0920539663debc23c397c9e46bebbea5
parente7d1fcd037d7f66ac2b7e891971fd2140c356d61 (diff)
downloaddevice-ti-proprietary-open-34dceb6b8f0783c045442d904e2bbb1f6bce0686.tar.gz
device-ti-proprietary-open-34dceb6b8f0783c045442d904e2bbb1f6bce0686.tar.xz
device-ti-proprietary-open-34dceb6b8f0783c045442d904e2bbb1f6bce0686.zip
SGX-BIN: DDK binaries and KM source with Post2 fix
DDK binaries and KM source. This version has Post2 fix for HWC to post NV12 layers. Change-Id: I88d9cf4df6ee8ebc96ffd051252b94bded68caaa Signed-off-by: Hemant Hariyani <hemanthariyani@ti.com>
-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);