1 /**********************************************************************
3 * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved.
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.
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.
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.
18 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
21 * Contact Information:
22 * Imagination Technologies Ltd. <gpl-support@imgtec.com>
23 * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
25 ******************************************************************************/
30 #include "sysconfig.h"
32 #include "servicesint.h"
38 #include "buffer_manager.h"
40 #include <linux/platform_device.h>
41 #include <linux/pvr.h>
43 #if defined(NO_HARDWARE) && defined(__KERNEL__)
47 struct SYS_DEVICE_ID {
53 #define SYS_MAX_LOCAL_DEVMEM_ARENAS 4
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;
68 void *hSOCTimerRegisterOSMemHandle;
69 u32 *pvSOCTimerRegisterKM;
70 void *pvSOCClockGateRegsBase;
71 u32 ui32SOCClockGateRegsSize;
72 IMG_BOOL (**ppfnCmdProcList[SYS_DEVICE_COUNT])(void *, u32, void *);
74 struct COMMAND_COMPLETE_DATA **ppsCmdCompleteData[SYS_DEVICE_COUNT];
76 struct RA_ARENA *apsLocalDevMemArena[SYS_MAX_LOCAL_DEVMEM_ARENAS];
78 char *pszVersionString;
79 struct PVRSRV_EVENTOBJECT *psGlobalEventObject;
85 enum PVRSRV_ERROR SysInitialise(struct platform_device *spd);
86 enum PVRSRV_ERROR SysFinalise(void);
88 enum PVRSRV_ERROR SysDeinitialise(struct SYS_DATA *psSysData);
90 enum PVRSRV_ERROR SysGetDeviceMemoryMap(enum PVRSRV_DEVICE_TYPE eDeviceType,
93 void SysRegisterExternalDevice(struct PVRSRV_DEVICE_NODE *psDeviceNode);
94 void SysRemoveExternalDevice(struct PVRSRV_DEVICE_NODE *psDeviceNode);
96 u32 SysGetInterruptSource(struct SYS_DATA *psSysData,
97 struct PVRSRV_DEVICE_NODE *psDeviceNode);
99 void SysClearInterrupts(struct SYS_DATA *psSysData,
102 enum PVRSRV_ERROR SysResetDevice(u32 ui32DeviceIndex);
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,
114 enum PVRSRV_ERROR SysOEMFunction(u32 ui32ID,
117 void *pvOut, u32 ulOutSize);
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);
131 extern struct SYS_DATA *gpsSysData;
134 static inline enum PVRSRV_ERROR SysAcquireData(struct SYS_DATA **ppsSysData)
136 *ppsSysData = gpsSysData;
139 return PVRSRV_ERROR_GENERIC;
144 static inline enum PVRSRV_ERROR SysInitialiseCommon(struct SYS_DATA *psSysData)
146 enum PVRSRV_ERROR eError;
147 eError = PVRSRVInit(psSysData);
151 static inline void SysDeinitialiseCommon(struct SYS_DATA *psSysData)
153 PVRSRVDeInit(psSysData);
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)
160 static inline u32 SysReadHWReg(void *pvLinRegBaseAddr, u32 ui32Offset)
162 return (u32)readl(pvLinRegBaseAddr + ui32Offset);
165 static inline void SysWriteHWReg(void *pvLinRegBaseAddr, u32 ui32Offset,
168 writel(ui32Value, pvLinRegBaseAddr + ui32Offset);
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);