RK3368 GPU version Rogue M 1.28
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue_m / system / include / syscommon.h
1 /*************************************************************************/ /*!
2 @File
3 @Title          Common System APIs and structures
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    This header provides common system-specific declarations and macros
6                 that are supported by all systems
7 @License        Dual MIT/GPLv2
8
9 The contents of this file are subject to the MIT license as set out below.
10
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is
16 furnished to do so, subject to the following conditions:
17
18 The above copyright notice and this permission notice shall be included in
19 all copies or substantial portions of the Software.
20
21 Alternatively, the contents of this file may be used under the terms of
22 the GNU General Public License Version 2 ("GPL") in which case the provisions
23 of GPL are applicable instead of those above.
24
25 If you wish to allow use of your version of this file only under the terms of
26 GPL, and not to allow others to use your version of this file under the terms
27 of the MIT license, indicate your decision by deleting the provisions above
28 and replace them with the notice and other provisions required by GPL as set
29 out in the file called "GPL-COPYING" included in this distribution. If you do
30 not delete the provisions above, a recipient may use your version of this file
31 under the terms of either the MIT license or GPL.
32
33 This License is also included in this distribution in the file called
34 "MIT-COPYING".
35
36 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
37 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
38 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
39 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
40 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
41 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
42 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43 */ /**************************************************************************/
44
45 #ifndef _SYSCOMMON_H
46 #define _SYSCOMMON_H
47
48 #include "osfunc.h"
49
50 #if defined(NO_HARDWARE) && defined(__linux__) && defined(__KERNEL__)
51 #include <asm/io.h>
52 #endif
53
54 #if defined (__cplusplus)
55 extern "C" {
56 #endif
57 #include "pvrsrv.h"
58
59 PVRSRV_ERROR SysCreateConfigData(PVRSRV_SYSTEM_CONFIG **ppsSysConfig, void *hDevice);
60 IMG_VOID SysDestroyConfigData(PVRSRV_SYSTEM_CONFIG *psSysConfig);
61 PVRSRV_ERROR SysAcquireSystemData(IMG_HANDLE hSysData);
62 PVRSRV_ERROR SysReleaseSystemData(IMG_HANDLE hSysData);
63 PVRSRV_ERROR SysDebugInfo(PVRSRV_SYSTEM_CONFIG *psSysConfig, DUMPDEBUG_PRINTF_FUNC *pfnDumpDebugPrintf);
64
65 #if defined(SUPPORT_GPUVIRT_VALIDATION)
66 #include "services.h"
67 IMG_VOID SysSetOSidRegisters(IMG_UINT32 aui32OSidMin[GPUVIRT_VALIDATION_NUM_OS][GPUVIRT_VALIDATION_NUM_REGIONS], IMG_UINT32 aui32OSidMax[GPUVIRT_VALIDATION_NUM_OS][GPUVIRT_VALIDATION_NUM_REGIONS]);
68 IMG_VOID SysPrintAndResetFaultStatusRegister(void);
69 #endif
70
71 #if defined(SUPPORT_SYSTEM_INTERRUPT_HANDLING)
72 PVRSRV_ERROR SysInstallDeviceLISR(IMG_UINT32 ui32IRQ,
73                                   IMG_CHAR *pszName,
74                                   PFN_LISR pfnLISR,
75                                   IMG_PVOID pvData,
76                                   IMG_HANDLE *phLISRData);
77
78 PVRSRV_ERROR SysUninstallDeviceLISR(IMG_HANDLE hLISRData);
79
80 #if defined(SUPPORT_DRM)
81 IMG_BOOL SystemISRHandler(IMG_VOID *pvData);
82 #endif
83 #endif /* defined(SUPPORT_SYSTEM_INTERRUPT_HANDLING) */
84
85
86 /*
87  * SysReadHWReg and SysWriteHWReg differ from OSReadHWReg and OSWriteHWReg
88  * in that they are always intended for use with real hardware, even on
89  * NO_HARDWARE systems.
90  */
91 #if !(defined(NO_HARDWARE) && defined(__linux__) && defined(__KERNEL__))
92 #define SysReadHWReg(p, o) OSReadHWReg(p, o)
93 #define SysWriteHWReg(p, o, v) OSWriteHWReg(p, o, v)
94 #else   /* !(defined(NO_HARDWARE) && defined(__linux__)) */
95 /*!
96 ******************************************************************************
97
98  @Function      SysReadHWReg
99
100  @Description
101
102  register read function
103
104  @input pvLinRegBaseAddr :      lin addr of register block base
105
106  @input ui32Offset :
107
108  @Return   register value
109
110 ******************************************************************************/
111 static inline IMG_UINT32 SysReadHWReg(IMG_PVOID pvLinRegBaseAddr, IMG_UINT32 ui32Offset)
112 {
113         return (IMG_UINT32) readl(pvLinRegBaseAddr + ui32Offset);
114 }
115
116 /*!
117 ******************************************************************************
118
119  @Function      SysWriteHWReg
120
121  @Description
122
123  register write function
124
125  @input pvLinRegBaseAddr :      lin addr of register block base
126
127  @input ui32Offset :
128
129  @input ui32Value :
130
131  @Return   none
132
133 ******************************************************************************/
134 static inline IMG_VOID SysWriteHWReg(IMG_PVOID pvLinRegBaseAddr, IMG_UINT32 ui32Offset, IMG_UINT32 ui32Value)
135 {
136         writel(ui32Value, pvLinRegBaseAddr + ui32Offset);
137 }
138 #endif  /* !(defined(NO_HARDWARE) && defined(__linux__)) */
139
140 /*!
141 ******************************************************************************
142
143  @Function              SysCheckMemAllocSize
144
145  @Description   Function to apply memory budgeting policies
146
147  @input                 psDevNode
148
149  @input                 uiChunkSize
150
151  @input                 ui32NumPhysChunks
152
153  @Return                PVRSRV_ERROR
154
155 ******************************************************************************/
156 FORCE_INLINE PVRSRV_ERROR SysCheckMemAllocSize(struct _PVRSRV_DEVICE_NODE_ *psDevNode,
157                                                                                                 IMG_UINT64 ui64MemSize)
158 {
159         PVR_UNREFERENCED_PARAMETER(psDevNode);
160         PVR_UNREFERENCED_PARAMETER(ui64MemSize);
161
162         return PVRSRV_OK;
163 }
164
165 #if defined(__cplusplus)
166 }
167 #endif
168
169 #endif
170
171 /*****************************************************************************
172  End of file (syscommon.h)
173 *****************************************************************************/