diff options
Diffstat (limited to 'drivers/gpu/pvr/omap4/sysutils_linux_wqueue_compat.c')
-rw-r--r-- | drivers/gpu/pvr/omap4/sysutils_linux_wqueue_compat.c | 238 |
1 files changed, 238 insertions, 0 deletions
diff --git a/drivers/gpu/pvr/omap4/sysutils_linux_wqueue_compat.c b/drivers/gpu/pvr/omap4/sysutils_linux_wqueue_compat.c new file mode 100644 index 00000000000..fa0cc696f80 --- /dev/null +++ b/drivers/gpu/pvr/omap4/sysutils_linux_wqueue_compat.c | |||
@@ -0,0 +1,238 @@ | |||
1 | /********************************************************************** | ||
2 | * | ||
3 | * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms and conditions of the GNU General Public License, | ||
7 | * version 2, as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope it will be useful but, except | ||
10 | * as otherwise stated in writing, without any warranty; without even the | ||
11 | * implied warranty of merchantability or fitness for a particular purpose. | ||
12 | * See the GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along with | ||
15 | * this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
17 | * | ||
18 | * The full GNU General Public License is included in this distribution in | ||
19 | * the file called "COPYING". | ||
20 | * | ||
21 | * Contact Information: | ||
22 | * Imagination Technologies Ltd. <gpl-support@imgtec.com> | ||
23 | * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK | ||
24 | * | ||
25 | ******************************************************************************/ | ||
26 | |||
27 | #include <linux/version.h> | ||
28 | #include <linux/clk.h> | ||
29 | #include <linux/err.h> | ||
30 | #include <linux/hardirq.h> | ||
31 | #include <linux/mutex.h> | ||
32 | |||
33 | #include "sgxdefs.h" | ||
34 | #include "services_headers.h" | ||
35 | #include "sysinfo.h" | ||
36 | #include "sgxapi_km.h" | ||
37 | #include "sysconfig.h" | ||
38 | #include "sgxinfokm.h" | ||
39 | #include "syslocal.h" | ||
40 | |||
41 | #if !defined(PVR_LINUX_USING_WORKQUEUES) | ||
42 | #error "PVR_LINUX_USING_WORKQUEUES must be defined" | ||
43 | #endif | ||
44 | |||
45 | #define ONE_MHZ 1000000 | ||
46 | #define HZ_TO_MHZ(m) ((m) / ONE_MHZ) | ||
47 | |||
48 | #if defined(SUPPORT_OMAP3430_SGXFCLK_96M) | ||
49 | #define SGX_PARENT_CLOCK "cm_96m_fck" | ||
50 | #else | ||
51 | #define SGX_PARENT_CLOCK "core_ck" | ||
52 | #endif | ||
53 | |||
54 | PVRSRV_ERROR SysPowerLockWrap(SYS_DATA unref__ *psSysData) | ||
55 | { | ||
56 | return PVRSRV_OK; | ||
57 | } | ||
58 | |||
59 | IMG_VOID SysPowerLockUnwrap(SYS_DATA unref__ *psSysData) | ||
60 | { | ||
61 | } | ||
62 | |||
63 | IMG_BOOL WrapSystemPowerChange(SYS_SPECIFIC_DATA *psSysSpecData) | ||
64 | { | ||
65 | return IMG_TRUE; | ||
66 | } | ||
67 | |||
68 | IMG_VOID UnwrapSystemPowerChange(SYS_SPECIFIC_DATA *psSysSpecData) | ||
69 | { | ||
70 | } | ||
71 | |||
72 | static inline IMG_UINT32 scale_by_rate(IMG_UINT32 val, IMG_UINT32 rate1, IMG_UINT32 rate2) | ||
73 | { | ||
74 | if (rate1 >= rate2) | ||
75 | { | ||
76 | return val * (rate1 / rate2); | ||
77 | } | ||
78 | |||
79 | return val / (rate2 / rate1); | ||
80 | } | ||
81 | |||
82 | static inline IMG_UINT32 scale_prop_to_SGX_clock(IMG_UINT32 val, IMG_UINT32 rate) | ||
83 | { | ||
84 | return scale_by_rate(val, rate, SYS_SGX_CLOCK_SPEED); | ||
85 | } | ||
86 | |||
87 | static inline IMG_UINT32 scale_inv_prop_to_SGX_clock(IMG_UINT32 val, IMG_UINT32 rate) | ||
88 | { | ||
89 | return scale_by_rate(val, SYS_SGX_CLOCK_SPEED, rate); | ||
90 | } | ||
91 | |||
92 | IMG_VOID SysGetSGXTimingInformation(SGX_TIMING_INFORMATION *psTimingInfo) | ||
93 | { | ||
94 | IMG_UINT32 rate; | ||
95 | |||
96 | #if defined(NO_HARDWARE) | ||
97 | rate = SYS_SGX_CLOCK_SPEED; | ||
98 | #else | ||
99 | PVR_ASSERT(atomic_read(&gpsSysSpecificData->sSGXClocksEnabled) != 0); | ||
100 | |||
101 | rate = SYS_SGX_CLOCK_SPEED; | ||
102 | PVR_ASSERT(rate != 0); | ||
103 | #endif | ||
104 | psTimingInfo->ui32CoreClockSpeed = rate; | ||
105 | psTimingInfo->ui32HWRecoveryFreq = scale_prop_to_SGX_clock(SYS_SGX_HWRECOVERY_TIMEOUT_FREQ, rate); | ||
106 | psTimingInfo->ui32uKernelFreq = scale_prop_to_SGX_clock(SYS_SGX_PDS_TIMER_FREQ, rate); | ||
107 | #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) | ||
108 | psTimingInfo->bEnableActivePM = IMG_TRUE; | ||
109 | #else | ||
110 | psTimingInfo->bEnableActivePM = IMG_FALSE; | ||
111 | #endif | ||
112 | psTimingInfo->ui32ActivePowManLatencyms = SYS_SGX_ACTIVE_POWER_LATENCY_MS; | ||
113 | } | ||
114 | |||
115 | PVRSRV_ERROR EnableSGXClocks(SYS_DATA *psSysData) | ||
116 | { | ||
117 | #if !defined(NO_HARDWARE) | ||
118 | SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData; | ||
119 | |||
120 | if (atomic_read(&psSysSpecData->sSGXClocksEnabled) != 0) | ||
121 | { | ||
122 | return PVRSRV_OK; | ||
123 | } | ||
124 | |||
125 | PVR_DPF((PVR_DBG_MESSAGE, "EnableSGXClocks: Enabling SGX Clocks")); | ||
126 | |||
127 | |||
128 | atomic_set(&psSysSpecData->sSGXClocksEnabled, 1); | ||
129 | |||
130 | #else | ||
131 | PVR_UNREFERENCED_PARAMETER(psSysData); | ||
132 | #endif | ||
133 | return PVRSRV_OK; | ||
134 | } | ||
135 | |||
136 | |||
137 | IMG_VOID DisableSGXClocks(SYS_DATA *psSysData) | ||
138 | { | ||
139 | #if !defined(NO_HARDWARE) | ||
140 | SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData; | ||
141 | |||
142 | |||
143 | if (atomic_read(&psSysSpecData->sSGXClocksEnabled) == 0) | ||
144 | { | ||
145 | return; | ||
146 | } | ||
147 | |||
148 | PVR_DPF((PVR_DBG_MESSAGE, "DisableSGXClocks: Disabling SGX Clocks")); | ||
149 | |||
150 | atomic_set(&psSysSpecData->sSGXClocksEnabled, 0); | ||
151 | |||
152 | #else | ||
153 | PVR_UNREFERENCED_PARAMETER(psSysData); | ||
154 | #endif | ||
155 | } | ||
156 | |||
157 | PVRSRV_ERROR EnableSystemClocks(SYS_DATA *psSysData) | ||
158 | { | ||
159 | SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData; | ||
160 | struct clk *psCLK; | ||
161 | IMG_INT res; | ||
162 | PVRSRV_ERROR eError; | ||
163 | |||
164 | #if defined(DEBUG) || defined(TIMING) | ||
165 | IMG_INT rate; | ||
166 | struct clk *sys_ck; | ||
167 | IMG_CPU_PHYADDR TimerRegPhysBase; | ||
168 | IMG_HANDLE hTimerEnable; | ||
169 | IMG_UINT32 *pui32TimerEnable; | ||
170 | |||
171 | #endif | ||
172 | |||
173 | PVR_TRACE(("EnableSystemClocks: Enabling System Clocks")); | ||
174 | |||
175 | if (!psSysSpecData->bSysClocksOneTimeInit) | ||
176 | { | ||
177 | mutex_init(&psSysSpecData->sPowerLock); | ||
178 | |||
179 | atomic_set(&psSysSpecData->sSGXClocksEnabled, 0); | ||
180 | psSysSpecData->bSysClocksOneTimeInit = IMG_TRUE; | ||
181 | } | ||
182 | |||
183 | eError = PVRSRV_OK; | ||
184 | goto Exit; | ||
185 | |||
186 | #if !defined(NO_OMAP_TIMER) | ||
187 | #if defined(DEBUG) || defined(TIMING) | ||
188 | ExitDisableGPT11ICK: | ||
189 | ExitDisableGPT11FCK: | ||
190 | ExitUnRegisterConstraintNotifications: | ||
191 | #endif | ||
192 | #endif | ||
193 | Exit: | ||
194 | return eError; | ||
195 | } | ||
196 | |||
197 | IMG_VOID DisableSystemClocks(SYS_DATA *psSysData) | ||
198 | { | ||
199 | #if !defined(NO_OMAP_TIMER) | ||
200 | #if defined(DEBUG) || defined(TIMING) | ||
201 | SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData; | ||
202 | IMG_CPU_PHYADDR TimerRegPhysBase; | ||
203 | IMG_HANDLE hTimerDisable; | ||
204 | IMG_UINT32 *pui32TimerDisable; | ||
205 | #endif | ||
206 | #endif | ||
207 | |||
208 | PVR_TRACE(("DisableSystemClocks: Disabling System Clocks")); | ||
209 | |||
210 | DisableSGXClocks(psSysData); | ||
211 | |||
212 | #if !defined(NO_OMAP_TIMER) | ||
213 | #if defined(DEBUG) || defined(TIMING) | ||
214 | |||
215 | TimerRegPhysBase.uiAddr = SYS_OMAP3430_GP11TIMER_ENABLE_SYS_PHYS_BASE; | ||
216 | pui32TimerDisable = OSMapPhysToLin(TimerRegPhysBase, | ||
217 | 4, | ||
218 | PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED, | ||
219 | &hTimerDisable); | ||
220 | |||
221 | if (pui32TimerDisable == IMG_NULL) | ||
222 | { | ||
223 | PVR_DPF((PVR_DBG_ERROR, "DisableSystemClocks: OSMapPhysToLin failed")); | ||
224 | } | ||
225 | else | ||
226 | { | ||
227 | *pui32TimerDisable = 0; | ||
228 | |||
229 | OSUnMapPhysToLin(pui32TimerDisable, | ||
230 | 4, | ||
231 | PVRSRV_HAP_KERNEL_ONLY|PVRSRV_HAP_UNCACHED, | ||
232 | hTimerDisable); | ||
233 | } | ||
234 | |||
235 | |||
236 | #endif | ||
237 | #endif | ||
238 | } | ||