[android-sdk/device-ti-proprietary-open.git] / omap5 / sgx_src / eurasia_km / services4 / system / omap4 / syslocal.h
1 /*************************************************************************/ /*!
2 @Title Local system definitions
3 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 @Description This header provides local system declarations and macros
5 @License Dual MIT/GPLv2
7 The contents of this file are subject to the MIT license as set out below.
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
19 Alternatively, the contents of this file may be used under the terms of
20 the GNU General Public License Version 2 ("GPL") in which case the provisions
21 of GPL are applicable instead of those above.
23 If you wish to allow use of your version of this file only under the terms of
24 GPL, and not to allow others to use your version of this file under the terms
25 of the MIT license, indicate your decision by deleting the provisions above
26 and replace them with the notice and other provisions required by GPL as set
27 out in the file called "GPL-COPYING" included in this distribution. If you do
28 not delete the provisions above, a recipient may use your version of this file
29 under the terms of either the MIT license or GPL.
31 This License is also included in this distribution in the file called
32 "MIT-COPYING".
34 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
35 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
38 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 */ /**************************************************************************/
43 #if !defined(__SYSLOCAL_H__)
44 #define __SYSLOCAL_H__
46 #if defined(__linux__)
48 #include <linux/version.h>
49 #include <linux/clk.h>
50 #if defined(PVR_LINUX_USING_WORKQUEUES)
51 #include <linux/mutex.h>
52 #else
53 #include <linux/spinlock.h>
54 #endif
55 #include <asm/atomic.h>
57 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26))
58 #include <linux/semaphore.h>
59 #include <linux/resource.h>
60 #else /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)) */
61 #include <asm/semaphore.h>
62 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22))
63 #include <asm/arch/resource.h>
64 #endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22)) */
65 #endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)) */
68 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
69 #if !defined(LDM_PLATFORM)
70 #error "LDM_PLATFORM must be set"
71 #endif
72 #define PVR_LINUX_DYNAMIC_SGX_RESOURCE_INFO
73 #include <linux/platform_device.h>
74 #endif
76 #if ((defined(DEBUG) || defined(TIMING)) && \
77 (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,34))) && \
78 !defined(PVR_NO_OMAP_TIMER)
79 /*
80 * We need to explicitly enable the GPTIMER11 clocks, or we'll get an
81 * abort when we try to access the timer registers.
82 */
83 #define PVR_OMAP4_TIMING_PRCM
84 #endif
86 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
87 #include <plat/gpu.h>
88 #if !defined(PVR_NO_OMAP_TIMER)
89 #define PVR_OMAP_USE_DM_TIMER_API
90 #include <plat/dmtimer.h>
91 #endif
92 #endif
94 #if defined(CONFIG_HAS_WAKELOCK)
95 #include <linux/wakelock.h>
96 #endif
98 #if !defined(PVR_NO_OMAP_TIMER)
99 #define PVR_OMAP_TIMER_BASE_IN_SYS_SPEC_DATA
100 #endif
101 #endif /* defined(__linux__) */
103 #if !defined(NO_HARDWARE) && \
104 defined(SYS_USING_INTERRUPTS)
105 #define SGX_OCP_REGS_ENABLED
106 #endif
108 #if defined(__linux__)
109 #if defined(SGX_OCP_REGS_ENABLED)
110 #define SGX_OCP_NO_INT_BYPASS
111 #endif
112 #endif
114 #if defined (__cplusplus)
115 extern "C" {
116 #endif
118 /*****************************************************************************
119 * system specific data structures
120 *****************************************************************************/
122 /*****************************************************************************
123 * system specific function prototypes
124 *****************************************************************************/
126 IMG_VOID DisableSystemClocks(SYS_DATA *psSysData);
127 PVRSRV_ERROR EnableSystemClocks(SYS_DATA *psSysData);
129 IMG_VOID DisableSGXClocks(SYS_DATA *psSysData);
130 PVRSRV_ERROR EnableSGXClocks(SYS_DATA *psSysData);
132 /*
133 * Various flags to indicate what has been initialised, and what
134 * has been temporarily deinitialised for power management purposes.
135 */
136 #define SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS 0x00000001
137 #define SYS_SPECIFIC_DATA_ENABLE_LISR 0x00000002
138 #define SYS_SPECIFIC_DATA_ENABLE_MISR 0x00000004
139 #define SYS_SPECIFIC_DATA_ENABLE_ENVDATA 0x00000008
140 #define SYS_SPECIFIC_DATA_ENABLE_LOCDEV 0x00000010
141 #define SYS_SPECIFIC_DATA_ENABLE_REGDEV 0x00000020
142 #define SYS_SPECIFIC_DATA_ENABLE_PDUMPINIT 0x00000040
143 #define SYS_SPECIFIC_DATA_ENABLE_INITDEV 0x00000080
144 #define SYS_SPECIFIC_DATA_ENABLE_LOCATEDEV 0x00000100
146 #define SYS_SPECIFIC_DATA_PM_UNINSTALL_LISR 0x00000200
147 #define SYS_SPECIFIC_DATA_PM_DISABLE_SYSCLOCKS 0x00000400
148 #define SYS_SPECIFIC_DATA_ENABLE_OCPREGS 0x00000800
149 #define SYS_SPECIFIC_DATA_ENABLE_PM_RUNTIME 0x00001000
150 #define SYS_SPECIFIC_DATA_IRQ_ENABLED 0x00002000
151 #define SYS_SPECIFIC_DATA_DVFS_INIT 0x00004000
153 #define SYS_SPECIFIC_DATA_SET(psSysSpecData, flag) ((IMG_VOID)((psSysSpecData)->ui32SysSpecificData |= (flag)))
155 #define SYS_SPECIFIC_DATA_CLEAR(psSysSpecData, flag) ((IMG_VOID)((psSysSpecData)->ui32SysSpecificData &= ~(flag)))
157 #define SYS_SPECIFIC_DATA_TEST(psSysSpecData, flag) (((psSysSpecData)->ui32SysSpecificData & (flag)) != 0)
159 typedef struct _SYS_SPECIFIC_DATA_TAG_
160 {
161 IMG_UINT32 ui32SysSpecificData;
162 PVRSRV_DEVICE_NODE *psSGXDevNode;
163 IMG_BOOL bSGXInitComplete;
164 #if defined(PVR_OMAP_TIMER_BASE_IN_SYS_SPEC_DATA)
165 IMG_CPU_PHYADDR sTimerRegPhysBase;
166 #endif
167 #if !defined(__linux__)
168 IMG_BOOL bSGXClocksEnabled;
169 #endif
170 IMG_UINT32 ui32SrcClockDiv;
171 #if defined(__linux__)
172 IMG_BOOL bSysClocksOneTimeInit;
173 atomic_t sSGXClocksEnabled;
174 #if defined(PVR_LINUX_USING_WORKQUEUES)
175 struct mutex sPowerLock;
176 #else
177 IMG_BOOL bConstraintNotificationsEnabled;
178 spinlock_t sPowerLock;
179 atomic_t sPowerLockCPU;
180 spinlock_t sNotifyLock;
181 atomic_t sNotifyLockCPU;
182 IMG_BOOL bCallVDD2PostFunc;
183 #endif
184 #if defined(DEBUG) || defined(TIMING)
185 struct clk *psGPT11_FCK;
186 struct clk *psGPT11_ICK;
187 #endif
188 #if defined(PVR_OMAP_USE_DM_TIMER_API)
189 struct omap_dm_timer *psGPTimer;
190 #endif
191 #if defined(CONFIG_HAS_WAKELOCK)
192 struct wake_lock wake_lock;
193 #endif /* CONFIG_HAS_WAKELOCK */
194 #endif /* defined(__linux__) */
195 } SYS_SPECIFIC_DATA;
197 extern SYS_SPECIFIC_DATA *gpsSysSpecificData;
199 #if defined(SGX_OCP_REGS_ENABLED) && defined(SGX_OCP_NO_INT_BYPASS)
200 IMG_VOID SysEnableSGXInterrupts(SYS_DATA* psSysData);
201 IMG_VOID SysDisableSGXInterrupts(SYS_DATA* psSysData);
202 #else
203 #define SysEnableSGXInterrupts(psSysData)
204 #define SysDisableSGXInterrupts(psSysData)
205 #endif
207 #if defined(SYS_CUSTOM_POWERLOCK_WRAP)
208 IMG_BOOL WrapSystemPowerChange(SYS_SPECIFIC_DATA *psSysSpecData);
209 IMG_VOID UnwrapSystemPowerChange(SYS_SPECIFIC_DATA *psSysSpecData);
210 #endif
212 #if defined(__linux__)
214 PVRSRV_ERROR SysPMRuntimeRegister(SYS_SPECIFIC_DATA *psSysSpecificData);
215 PVRSRV_ERROR SysPMRuntimeUnregister(SYS_SPECIFIC_DATA *psSysSpecificData);
217 PVRSRV_ERROR SysDvfsInitialize(SYS_SPECIFIC_DATA *psSysSpecificData);
218 PVRSRV_ERROR SysDvfsDeinitialize(SYS_SPECIFIC_DATA *psSysSpecificData);
219 int pvr_access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
221 #else /* defined(__linux__) */
223 #ifdef INLINE_IS_PRAGMA
224 #pragma inline(SysPMRuntimeRegister)
225 #endif
226 static INLINE PVRSRV_ERROR SysPMRuntimeRegister(void)
227 {
228 return PVRSRV_OK;
229 }
231 #ifdef INLINE_IS_PRAGMA
232 #pragma inline(SysPMRuntimeUnregister)
233 #endif
234 static INLINE PVRSRV_ERROR SysPMRuntimeUnregister(void)
235 {
236 return PVRSRV_OK;
237 }
239 #ifdef INLINE_IS_PRAGMA
240 #pragma inline(SysDvfsInitialize)
241 #endif
242 static INLINE PVRSRV_ERROR SysDvfsInitialize(void)
243 {
244 return PVRSRV_OK;
245 }
247 #ifdef INLINE_IS_PRAGMA
248 #pragma inline(SysDvfsDeinitialize)
249 #endif
250 static INLINE PVRSRV_ERROR SysDvfsDeinitialize(void)
251 {
252 return PVRSRV_OK;
253 }
255 #define pvr_access_process_vm(tsk, addr, buf, len, write) -1
257 #endif /* defined(__linux__) */
259 #if defined(__cplusplus)
260 }
261 #endif
263 #endif /* __SYSLOCAL_H__ */