RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / pvrsrv_device.h
1 /**************************************************************************/ /*!
2 @File
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
42 #ifndef __PVRSRV_DEVICE_H__
43 #define __PVRSRV_DEVICE_H__
44
45 #include "img_types.h"
46 #include "physheap.h"
47 #include "pvrsrv_error.h"
48 #include "rgx_fwif_km.h"
49 #include "servicesext.h"
50
51 #if defined(PVR_DVFS) || defined(SUPPORT_PDVFS)
52 #include "pvr_dvfs.h"
53 #endif
54
55 typedef struct _PVRSRV_DEVICE_CONFIG_ PVRSRV_DEVICE_CONFIG;
56
57 /*
58  * All the heaps from which regular device memory allocations can be made in
59  * terms of their locality to the respective device.
60  */
61 typedef enum
62 {
63         PVRSRV_DEVICE_PHYS_HEAP_GPU_LOCAL = 0,
64         PVRSRV_DEVICE_PHYS_HEAP_CPU_LOCAL = 1,
65         PVRSRV_DEVICE_PHYS_HEAP_FW_LOCAL = 2,
66         PVRSRV_DEVICE_PHYS_HEAP_LAST
67 } PVRSRV_DEVICE_PHYS_HEAP;
68
69 typedef enum
70 {
71         PVRSRV_DEVICE_LOCAL_MEMORY_ARENA_MAPPABLE = 0,
72         PVRSRV_DEVICE_LOCAL_MEMORY_ARENA_NON_MAPPABLE = 1,
73         PVRSRV_DEVICE_LOCAL_MEMORY_ARENA_LAST
74 } PVRSRV_DEVICE_LOCAL_MEMORY_ARENA;
75
76 typedef enum _PVRSRV_DEVICE_SNOOP_MODE_
77 {
78         PVRSRV_DEVICE_SNOOP_NONE = 0,
79         PVRSRV_DEVICE_SNOOP_CPU_ONLY,
80         PVRSRV_DEVICE_SNOOP_DEVICE_ONLY,
81         PVRSRV_DEVICE_SNOOP_CROSS,
82 } PVRSRV_DEVICE_SNOOP_MODE;
83
84 typedef IMG_UINT32
85 (*PFN_SYS_DEV_CLK_FREQ_GET)(IMG_HANDLE hSysData);
86
87 typedef PVRSRV_ERROR
88 (*PFN_SYS_DEV_PRE_POWER)(IMG_HANDLE hSysData,
89                                                  PVRSRV_DEV_POWER_STATE eNewPowerState,
90                                                  PVRSRV_DEV_POWER_STATE eCurrentPowerState,
91                                                  IMG_BOOL bForced);
92
93 typedef PVRSRV_ERROR
94 (*PFN_SYS_DEV_POST_POWER)(IMG_HANDLE hSysData,
95                                                   PVRSRV_DEV_POWER_STATE eNewPowerState,
96                                                   PVRSRV_DEV_POWER_STATE eCurrentPowerState,
97                                                   IMG_BOOL bForced);
98
99 typedef void
100 (*PFN_SYS_DEV_INTERRUPT_HANDLED)(PVRSRV_DEVICE_CONFIG *psDevConfig);
101
102 typedef PVRSRV_ERROR
103 (*PFN_SYS_DEV_CHECK_MEM_ALLOC_SIZE)(IMG_HANDLE hSysData,
104                                                                         IMG_UINT64 ui64MemSize);
105
106 typedef void (*PFN_SYS_DEV_FEAT_DEP_INIT)(PVRSRV_DEVICE_CONFIG *, IMG_UINT64);
107
108 #if defined(SUPPORT_TRUSTED_DEVICE)
109
110 #define PVRSRV_DEVICE_FW_CODE_REGION          (0)
111 #define PVRSRV_DEVICE_FW_COREMEM_CODE_REGION  (1)
112
113 typedef struct _PVRSRV_TD_FW_PARAMS_
114 {
115         const void *pvFirmware;
116         IMG_UINT32 ui32FirmwareSize;
117         IMG_DEV_VIRTADDR sFWCodeDevVAddrBase;
118         IMG_DEV_VIRTADDR sFWDataDevVAddrBase;
119         RGXFWIF_DEV_VIRTADDR sFWCorememCodeFWAddr;
120         RGXFWIF_DEV_VIRTADDR sFWInitFWAddr;
121 } PVRSRV_TD_FW_PARAMS;
122
123 typedef PVRSRV_ERROR
124 (*PFN_TD_SEND_FW_IMAGE)(IMG_HANDLE hSysData,
125                                                 PVRSRV_TD_FW_PARAMS *psTDFWParams);
126
127 typedef struct _PVRSRV_TD_POWER_PARAMS_
128 {
129         IMG_DEV_PHYADDR sPCAddr; /* META only used param */
130
131         /* MIPS only used fields */
132         IMG_DEV_PHYADDR sGPURegAddr;
133         IMG_DEV_PHYADDR sBootRemapAddr;
134         IMG_DEV_PHYADDR sCodeRemapAddr;
135         IMG_DEV_PHYADDR sDataRemapAddr;
136 } PVRSRV_TD_POWER_PARAMS;
137
138 typedef PVRSRV_ERROR
139 (*PFN_TD_SET_POWER_PARAMS)(IMG_HANDLE hSysData,
140                                                    PVRSRV_TD_POWER_PARAMS *psTDPowerParams);
141
142 typedef PVRSRV_ERROR
143 (*PFN_TD_RGXSTART)(IMG_HANDLE hSysData);
144
145 typedef PVRSRV_ERROR
146 (*PFN_TD_RGXSTOP)(IMG_HANDLE hSysData);
147
148 typedef struct _PVRSRV_TD_SECBUF_PARAMS_
149 {
150         IMG_DEVMEM_SIZE_T uiSize;
151         IMG_DEVMEM_ALIGN_T uiAlign;
152         IMG_CPU_PHYADDR *psSecBufAddr;
153         IMG_UINT64 *pui64SecBufHandle;
154 } PVRSRV_TD_SECBUF_PARAMS;
155
156 typedef PVRSRV_ERROR
157 (*PFN_TD_SECUREBUF_ALLOC)(IMG_HANDLE hSysData,
158                                                   PVRSRV_TD_SECBUF_PARAMS *psTDSecBufParams);
159
160 typedef PVRSRV_ERROR
161 (*PFN_TD_SECUREBUF_FREE)(IMG_HANDLE hSysData,
162                                                  IMG_UINT64 ui64SecBufHandle);
163 #endif /* defined(SUPPORT_TRUSTED_DEVICE) */
164
165 struct _PVRSRV_DEVICE_CONFIG_
166 {
167         /*! OS device passed to SysDevInit (linux: 'struct device') */
168         void *pvOSDevice;
169
170         /*!
171          *! Service representation of pvOSDevice. Should be set to NULL when the
172          *! config is created in SysDevInit. Set by Services once a device node has
173          *! been created for this config and unset before SysDevDeInit is called.
174          */
175         struct _PVRSRV_DEVICE_NODE_ *psDevNode;
176
177         /*! Name of the device */
178         IMG_CHAR *pszName;
179
180         /*! Version of the device (optional) */
181         IMG_CHAR *pszVersion;
182
183         /*! Register bank address */
184         IMG_CPU_PHYADDR sRegsCpuPBase;
185         /*! Register bank size */
186         IMG_UINT32 ui32RegsSize;
187         /*! Device interrupt number */
188         IMG_UINT32 ui32IRQ;
189
190         PVRSRV_DEVICE_SNOOP_MODE eCacheSnoopingMode;
191
192         /*! Device specific data handle */
193         IMG_HANDLE hDevData;
194
195         /*! System specific data that gets passed into system callback functions. */
196         IMG_HANDLE hSysData;
197
198         IMG_BOOL bHasNonMappableLocalMemory;
199
200         PHYS_HEAP_CONFIG *pasPhysHeaps;
201         IMG_UINT32 ui32PhysHeapCount;
202
203         /*!
204          *! ID of the Physical memory heap to use.
205          *!
206          *! The first entry (aui32PhysHeapID[PVRSRV_DEVICE_PHYS_HEAP_GPU_LOCAL])
207          *! will be used for allocations where the PVRSRV_MEMALLOCFLAG_CPU_LOCAL
208          *! flag is not set. Normally this will be the PhysHeapID of an LMA heap
209          *! but the configuration could specify a UMA heap here (if desired).
210          *!
211          *! The second entry (aui32PhysHeapID[PVRSRV_DEVICE_PHYS_HEAP_CPU_LOCAL])
212          *! will be used for allocations where the PVRSRV_MEMALLOCFLAG_CPU_LOCAL
213          *! flag is set. Normally this will be the PhysHeapID of a UMA heap but
214          *! the configuration could specify an LMA heap here (if desired).
215          *!
216          *! The third entry (aui32PhysHeapID[PVRSRV_DEVICE_PHYS_HEAP_FW_LOCAL])
217          *! will be used for allocations where the PVRSRV_MEMALLOCFLAG_FW_LOCAL
218          *! flag is set.
219          *!
220          *! In the event of there being only one Physical Heap, the configuration
221          *! should specify the same heap details in all entries.
222          */
223         IMG_UINT32 aui32PhysHeapID[PVRSRV_DEVICE_PHYS_HEAP_LAST];
224
225         RGXFWIF_BIFTILINGMODE eBIFTilingMode;
226         IMG_UINT32 *pui32BIFTilingHeapConfigs;
227         IMG_UINT32 ui32BIFTilingHeapCount;
228
229         /*!
230          *! Callbacks to change system device power state at the beginning and end
231          *! of a power state change (optional).
232          */
233         PFN_SYS_DEV_PRE_POWER pfnPrePowerState;
234         PFN_SYS_DEV_POST_POWER pfnPostPowerState;
235
236         /*! Callback to obtain the clock frequency from the device (optional). */
237         PFN_SYS_DEV_CLK_FREQ_GET pfnClockFreqGet;
238
239         /*!
240          *! Callback to handle memory budgeting. Can be used to reject allocations
241          *! over a certain size (optional).
242          */
243         PFN_SYS_DEV_CHECK_MEM_ALLOC_SIZE pfnCheckMemAllocSize;
244
245 #if defined(SUPPORT_TRUSTED_DEVICE)
246         /*!
247          *! Callback to send FW image and FW boot time parameters to the trusted
248          *! device.
249          */
250         PFN_TD_SEND_FW_IMAGE pfnTDSendFWImage;
251
252         /*!
253          *! Callback to send parameters needed in a power transition to the trusted
254          *! device.
255          */
256         PFN_TD_SET_POWER_PARAMS pfnTDSetPowerParams;
257
258         /*! Callbacks to ping the trusted device to securely run RGXStart/Stop() */
259         PFN_TD_RGXSTART pfnTDRGXStart;
260         PFN_TD_RGXSTOP pfnTDRGXStop;
261
262         /*! Callback to request allocation/freeing of secure buffers */
263         PFN_TD_SECUREBUF_ALLOC pfnTDSecureBufAlloc;
264         PFN_TD_SECUREBUF_FREE pfnTDSecureBufFree;
265 #endif /* defined(SUPPORT_TRUSTED_DEVICE) */
266
267         /*! Function that does device feature specific system layer initialisation */
268         PFN_SYS_DEV_FEAT_DEP_INIT       pfnSysDevFeatureDepInit;
269
270 #if defined(PVR_DVFS) || defined(SUPPORT_PDVFS)
271         PVRSRV_DVFS sDVFS;
272 #endif
273 };
274
275 #endif /* __PVRSRV_DEVICE_H__*/