gpu: pvr: pdumpfs: add stream_frames debugfs entry
[sgx.git] / pvr / syscommon.h
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 #ifndef _SYSCOMMON_H
28 #define _SYSCOMMON_H
29
30 #include "sysconfig.h"
31 #include "sysinfo.h"
32 #include "servicesint.h"
33 #include "queue.h"
34 #include "power.h"
35 #include "resman.h"
36 #include "ra.h"
37 #include "device.h"
38 #include "buffer_manager.h"
39
40 #include <linux/platform_device.h>
41 #include <linux/pvr.h>
42
43 #if defined(NO_HARDWARE) && defined(__KERNEL__)
44 #include <linux/io.h>
45 #endif
46
47 struct SYS_DEVICE_ID {
48         u32 uiID;
49         IMG_BOOL bInUse;
50
51 };
52
53 #define SYS_MAX_LOCAL_DEVMEM_ARENAS     4
54
55 struct SYS_DATA {
56         u32 ui32NumDevices;
57         struct SYS_DEVICE_ID sDeviceID[SYS_DEVICE_COUNT];
58         struct PVRSRV_DEVICE_NODE *psDeviceNodeList;
59         struct PVRSRV_POWER_DEV *psPowerDeviceList;
60         enum PVR_POWER_STATE eCurrentPowerState;
61         enum PVR_POWER_STATE eFailedPowerState;
62         u32 ui32CurrentOSPowerState;
63         struct PVRSRV_QUEUE_INFO *psQueueList;
64         struct PVRSRV_KERNEL_SYNC_INFO *psSharedSyncInfoList;
65         void *pvEnvSpecificData;
66         void *pvSysSpecificData;
67         void *pvSOCRegsBase;
68         void *hSOCTimerRegisterOSMemHandle;
69         u32 *pvSOCTimerRegisterKM;
70         void *pvSOCClockGateRegsBase;
71         u32 ui32SOCClockGateRegsSize;
72         IMG_BOOL (**ppfnCmdProcList[SYS_DEVICE_COUNT])(void *, u32, void *);
73
74         struct COMMAND_COMPLETE_DATA **ppsCmdCompleteData[SYS_DEVICE_COUNT];
75
76         struct RA_ARENA *apsLocalDevMemArena[SYS_MAX_LOCAL_DEVMEM_ARENAS];
77
78         char *pszVersionString;
79         struct PVRSRV_EVENTOBJECT *psGlobalEventObject;
80 #if defined(PDUMP)
81         IMG_BOOL Unused;
82 #endif
83 };
84
85 enum PVRSRV_ERROR SysInitialise(struct platform_device *spd);
86 enum PVRSRV_ERROR SysFinalise(void);
87
88 enum PVRSRV_ERROR SysDeinitialise(struct SYS_DATA *psSysData);
89
90 enum PVRSRV_ERROR SysGetDeviceMemoryMap(enum PVRSRV_DEVICE_TYPE eDeviceType,
91                                    void **ppvDeviceMap);
92
93 void SysRegisterExternalDevice(struct PVRSRV_DEVICE_NODE *psDeviceNode);
94 void SysRemoveExternalDevice(struct PVRSRV_DEVICE_NODE *psDeviceNode);
95
96 u32 SysGetInterruptSource(struct SYS_DATA *psSysData,
97                                  struct PVRSRV_DEVICE_NODE *psDeviceNode);
98
99 void SysClearInterrupts(struct SYS_DATA *psSysData,
100                             u32 ui32ClearBits);
101
102 enum PVRSRV_ERROR SysResetDevice(u32 ui32DeviceIndex);
103
104 enum PVRSRV_ERROR SysSystemPrePowerState(enum PVR_POWER_STATE eNewPowerState);
105 enum PVRSRV_ERROR SysSystemPostPowerState(enum PVR_POWER_STATE eNewPowerState);
106 enum PVRSRV_ERROR SysDevicePrePowerState(u32 ui32DeviceIndex,
107                                     enum PVR_POWER_STATE eNewPowerState,
108                                     enum PVR_POWER_STATE eCurrentPowerState);
109 enum PVRSRV_ERROR SysDevicePostPowerState(u32 ui32DeviceIndex,
110                                      enum PVR_POWER_STATE eNewPowerState,
111                                      enum PVR_POWER_STATE
112                                      eCurrentPowerState);
113
114 enum PVRSRV_ERROR SysOEMFunction(u32 ui32ID,
115                             void *pvIn,
116                             u32 ulInSize,
117                             void *pvOut, u32 ulOutSize);
118
119 struct IMG_DEV_PHYADDR SysCpuPAddrToDevPAddr(
120                         enum PVRSRV_DEVICE_TYPE eDeviceType,
121                         struct IMG_CPU_PHYADDR cpu_paddr);
122 struct IMG_DEV_PHYADDR SysSysPAddrToDevPAddr(
123                         enum PVRSRV_DEVICE_TYPE eDeviceType,
124                         struct IMG_SYS_PHYADDR SysPAddr);
125 struct IMG_SYS_PHYADDR SysDevPAddrToSysPAddr(
126                         enum PVRSRV_DEVICE_TYPE eDeviceType,
127                         struct IMG_DEV_PHYADDR SysPAddr);
128 struct IMG_CPU_PHYADDR SysSysPAddrToCpuPAddr(struct IMG_SYS_PHYADDR SysPAddr);
129 struct IMG_SYS_PHYADDR SysCpuPAddrToSysPAddr(struct IMG_CPU_PHYADDR cpu_paddr);
130
131 extern struct SYS_DATA *gpsSysData;
132
133
134 static inline enum PVRSRV_ERROR SysAcquireData(struct SYS_DATA **ppsSysData)
135 {
136         *ppsSysData = gpsSysData;
137
138         if (!gpsSysData)
139                 return PVRSRV_ERROR_GENERIC;
140
141         return PVRSRV_OK;
142 }
143
144 static inline enum PVRSRV_ERROR SysInitialiseCommon(struct SYS_DATA *psSysData)
145 {
146         enum PVRSRV_ERROR eError;
147         eError = PVRSRVInit(psSysData);
148         return eError;
149 }
150
151 static inline void SysDeinitialiseCommon(struct SYS_DATA *psSysData)
152 {
153         PVRSRVDeInit(psSysData);
154 }
155
156 #if !(defined(NO_HARDWARE) && defined(__KERNEL__))
157 #define SysReadHWReg(p, o)      OSReadHWReg(p, o)
158 #define SysWriteHWReg(p, o, v)  OSWriteHWReg(p, o, v)
159 #else
160 static inline u32 SysReadHWReg(void *pvLinRegBaseAddr, u32 ui32Offset)
161 {
162         return (u32)readl(pvLinRegBaseAddr + ui32Offset);
163 }
164
165 static inline void SysWriteHWReg(void *pvLinRegBaseAddr, u32 ui32Offset,
166                                  u32 ui32Value)
167 {
168         writel(ui32Value, pvLinRegBaseAddr + ui32Offset);
169 }
170 #endif
171
172 bool sgx_is_530(void);
173 u32 sgx_get_rev(void);
174 void sgx_ocp_write_reg(u32 reg, u32 val);
175 unsigned long sgx_get_max_freq(void);
176
177 #endif