aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/ice4100/sgx535/system/include/syscommon.h
blob: 948773641381b05fcad43137fa42ec72585a4b3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
/**********************************************************************
 *
 * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful but, except
 * as otherwise stated in writing, without any warranty; without even the
 * implied warranty of merchantability or fitness for a particular purpose.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * The full GNU General Public License is included in this distribution in
 * the file called "COPYING".
 *
 * Contact Information:
 * Imagination Technologies Ltd. <gpl-support@imgtec.com>
 * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
 *
 ******************************************************************************/

#ifndef _SYSCOMMON_H
#define _SYSCOMMON_H

#include "sysconfig.h"
#include "sysinfo.h"
#include "servicesint.h"
#include "queue.h"
#include "power.h"
#include "resman.h"
#include "ra.h"
#include "device.h"
#include "buffer_manager.h"

#if defined(NO_HARDWARE) && defined(__linux__) && defined(__KERNEL__)
#include <asm/io.h>
#endif

typedef struct _SYS_DEVICE_ID_TAG
{
	u32	uiID;
	int	bInUse;

} SYS_DEVICE_ID;


#define SYS_MAX_LOCAL_DEVMEM_ARENAS	4

typedef struct _SYS_DATA_TAG_
{
    u32                  ui32NumDevices;
	SYS_DEVICE_ID				sDeviceID[SYS_DEVICE_COUNT];
    PVRSRV_DEVICE_NODE			*psDeviceNodeList;
    PVRSRV_POWER_DEV			*psPowerDeviceList;
	PVRSRV_RESOURCE				sPowerStateChangeResource;
   	PVRSRV_SYS_POWER_STATE		eCurrentPowerState;
   	PVRSRV_SYS_POWER_STATE		eFailedPowerState;
   	u32		 			ui32CurrentOSPowerState;
    PVRSRV_QUEUE_INFO           *psQueueList;
   	PVRSRV_KERNEL_SYNC_INFO 	*psSharedSyncInfoList;
    void *                   pvEnvSpecificData;
    void *                   pvSysSpecificData;
	PVRSRV_RESOURCE				sQProcessResource;
	void					*pvSOCRegsBase;
    void *                  hSOCTimerRegisterOSMemHandle;
	u32					*pvSOCTimerRegisterKM;
	void					*pvSOCClockGateRegsBase;
	u32					ui32SOCClockGateRegsSize;
	PFN_CMD_PROC				*ppfnCmdProcList[SYS_DEVICE_COUNT];



	PCOMMAND_COMPLETE_DATA		*ppsCmdCompleteData[SYS_DEVICE_COUNT];


	int                    bReProcessQueues;

	RA_ARENA					*apsLocalDevMemArena[SYS_MAX_LOCAL_DEVMEM_ARENAS];

    char                    *pszVersionString;
	PVRSRV_EVENTOBJECT			*psGlobalEventObject;

	int					bFlushAll;

} SYS_DATA;



PVRSRV_ERROR SysInitialise(void);
PVRSRV_ERROR SysFinalise(void);

PVRSRV_ERROR SysDeinitialise(SYS_DATA *psSysData);
PVRSRV_ERROR SysGetDeviceMemoryMap(PVRSRV_DEVICE_TYPE eDeviceType,
									void **ppvDeviceMap);

void SysRegisterExternalDevice(PVRSRV_DEVICE_NODE *psDeviceNode);
void SysRemoveExternalDevice(PVRSRV_DEVICE_NODE *psDeviceNode);

u32 SysGetInterruptSource(SYS_DATA			*psSysData,
								 PVRSRV_DEVICE_NODE *psDeviceNode);

void SysClearInterrupts(SYS_DATA* psSysData, u32 ui32ClearBits);

PVRSRV_ERROR SysResetDevice(u32 ui32DeviceIndex);

PVRSRV_ERROR SysSystemPrePowerState(PVRSRV_SYS_POWER_STATE eNewPowerState);
PVRSRV_ERROR SysSystemPostPowerState(PVRSRV_SYS_POWER_STATE eNewPowerState);
PVRSRV_ERROR SysDevicePrePowerState(u32 ui32DeviceIndex,
									PVRSRV_DEV_POWER_STATE eNewPowerState,
									PVRSRV_DEV_POWER_STATE eCurrentPowerState);
PVRSRV_ERROR SysDevicePostPowerState(u32 ui32DeviceIndex,
									 PVRSRV_DEV_POWER_STATE eNewPowerState,
									 PVRSRV_DEV_POWER_STATE eCurrentPowerState);

#if defined(SYS_CUSTOM_POWERLOCK_WRAP)
PVRSRV_ERROR SysPowerLockWrap(SYS_DATA *psSysData);
void SysPowerLockUnwrap(SYS_DATA *psSysData);
#endif

PVRSRV_ERROR SysOEMFunction (	u32	ui32ID,
								void	*pvIn,
								u32  ulInSize,
								void	*pvOut,
								u32	ulOutSize);


IMG_DEV_PHYADDR SysCpuPAddrToDevPAddr (PVRSRV_DEVICE_TYPE eDeviceType, IMG_CPU_PHYADDR cpu_paddr);
IMG_DEV_PHYADDR SysSysPAddrToDevPAddr (PVRSRV_DEVICE_TYPE eDeviceType, IMG_SYS_PHYADDR SysPAddr);
IMG_SYS_PHYADDR SysDevPAddrToSysPAddr (PVRSRV_DEVICE_TYPE eDeviceType, IMG_DEV_PHYADDR SysPAddr);
IMG_CPU_PHYADDR SysSysPAddrToCpuPAddr (IMG_SYS_PHYADDR SysPAddr);
IMG_SYS_PHYADDR SysCpuPAddrToSysPAddr (IMG_CPU_PHYADDR cpu_paddr);
#if defined(PVR_LMA)
int SysVerifyCpuPAddrToDevPAddr (PVRSRV_DEVICE_TYPE eDeviceType, IMG_CPU_PHYADDR CpuPAddr);
int SysVerifySysPAddrToDevPAddr (PVRSRV_DEVICE_TYPE eDeviceType, IMG_SYS_PHYADDR SysPAddr);
#endif

extern SYS_DATA* gpsSysData;

#if !defined(USE_CODE)

static PVRSRV_ERROR SysAcquireData(SYS_DATA **ppsSysData)
{

	*ppsSysData = gpsSysData;





	if (!gpsSysData)
	{
		return PVRSRV_ERROR_GENERIC;
   	}

	return PVRSRV_OK;
}


static PVRSRV_ERROR SysInitialiseCommon(SYS_DATA *psSysData)
{
	PVRSRV_ERROR	eError;


	eError = PVRSRVInit(psSysData);

	return eError;
}

static void SysDeinitialiseCommon(SYS_DATA *psSysData)
{

	PVRSRVDeInit(psSysData);

	OSDestroyResource(&psSysData->sPowerStateChangeResource);
}
#endif


#if !(defined(NO_HARDWARE) && defined(__linux__) && defined(__KERNEL__))
#define	SysReadHWReg(p, o) OSReadHWReg(p, o)
#define SysWriteHWReg(p, o, v) OSWriteHWReg(p, o, v)
#else
static inline u32 SysReadHWReg(void * pvLinRegBaseAddr, u32 ui32Offset)
{
	return (u32) readl(pvLinRegBaseAddr + ui32Offset);
}

static inline void SysWriteHWReg(void * pvLinRegBaseAddr, u32 ui32Offset, u32 ui32Value)
{
	writel(ui32Value, pvLinRegBaseAddr + ui32Offset);
}
#endif


#endif