aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/ice4100/sgx535/system/sgx_intel_ce/sysconfig.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/ice4100/sgx535/system/sgx_intel_ce/sysconfig.c')
-rwxr-xr-xdrivers/staging/ice4100/sgx535/system/sgx_intel_ce/sysconfig.c79
1 files changed, 69 insertions, 10 deletions
diff --git a/drivers/staging/ice4100/sgx535/system/sgx_intel_ce/sysconfig.c b/drivers/staging/ice4100/sgx535/system/sgx_intel_ce/sysconfig.c
index ad2d0196ae5..08363df0267 100755
--- a/drivers/staging/ice4100/sgx535/system/sgx_intel_ce/sysconfig.c
+++ b/drivers/staging/ice4100/sgx535/system/sgx_intel_ce/sysconfig.c
@@ -49,6 +49,8 @@
#include "graphics_pm.h"
#endif
+#include "linux/pci.h"
+
#define SYS_SGX_CLOCK_SPEED (400000000)
#define SYS_SGX_HWRECOVERY_TIMEOUT_FREQ (100)
#define SYS_SGX_PDS_TIMER_FREQ (1000)
@@ -67,10 +69,56 @@ extern struct pci_dev *gpsPVRLDMDev;
#endif
u32 PVRSRV_BridgeDispatchKM(u32 Ioctl,
- unsigned char * pInBuf,
- u32 InBufLen,
- unsigned char * pOutBuf,
- u32 OutBufLen, u32 * pdwBytesTransferred);
+ unsigned char * pInBuf,
+ u32 InBufLen,
+ unsigned char * pOutBuf,
+ u32 OutBufLen, u32 * pdwBytesTransferred);
+
+static PVRSRV_ERROR InitSGXPCIDev(SYS_DATA *psSysData)
+{
+ SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData;
+
+ struct pci_dev *psPCIDev = NULL;
+ psPCIDev = pci_get_device(SYS_SGX_DEV_VENDOR_ID, SYS_SGX_DEV_DEVICE_ID, NULL);
+ if (psPCIDev != NULL)
+ {
+ if (pci_enable_device(psPCIDev))
+ goto init_failed;
+
+ psSysSpecData->psSGXPCIDev = psPCIDev;
+
+ return PVRSRV_OK;
+ }
+
+init_failed:
+ psSysSpecData->psSGXPCIDev = NULL;
+ PVR_DPF((PVR_DBG_ERROR,"InitSGXPCIDev: failed to initialize the sgx PCI device!\n"));
+ return PVRSRV_ERROR_GENERIC;
+}
+
+static void DeinitSGXPCIDev(SYS_DATA *psSysData)
+{
+ SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData;
+
+ if (psSysSpecData->psSGXPCIDev != NULL)
+ {
+ pci_disable_device(psSysSpecData->psSGXPCIDev);
+ }
+}
+
+static PVRSRV_ERROR GetSGXPCIDevIRQ(SYS_DATA *psSysData, u32 *pui32IRQ)
+{
+ SYS_SPECIFIC_DATA *psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData;
+
+ if (psSysSpecData->psSGXPCIDev != NULL)
+ {
+ *pui32IRQ = psSysSpecData->psSGXPCIDev->irq;
+ return PVRSRV_OK;
+ }
+
+ return PVRSRV_ERROR_GENERIC;
+}
+
static PVRSRV_ERROR SysLocateDevices(SYS_DATA * psSysData)
{
@@ -88,14 +136,14 @@ static PVRSRV_ERROR SysLocateDevices(SYS_DATA * psSysData)
#define BAR0 0x10
-#define IRQ_LINE 0x3C
-#define IRQ_LINE_MASK 0xFF
-
ui32SGXRegBaseAddr = OSPCIReadDword(SGX_PCI_BUS,
SGX_PCI_DEV, SGX_PCI_FN, BAR0);
- ui32IRQ = OSPCIReadDword(SGX_PCI_BUS,
- SGX_PCI_DEV,
- SGX_PCI_FN, IRQ_LINE) & IRQ_LINE_MASK;
+ if(GetSGXPCIDevIRQ(psSysData, &ui32IRQ) != PVRSRV_OK)
+ {
+ PVR_DPF((PVR_DBG_ERROR, "sysLocateDevices: failed to get the pci IRQ!"));
+ return PVRSRV_ERROR_INVALID_DEVICE;
+ }
+
#endif
// This address was only ever used in the addr translation functions. We took
@@ -171,6 +219,15 @@ PVRSRV_ERROR SysInitialise(void)
SYS_SGX_ACTIVE_POWER_LATENCY_MS;
psTimingInfo->ui32uKernelFreq = SYS_SGX_PDS_TIMER_FREQ;
+ eError = InitSGXPCIDev(gpsSysData);
+ if (eError != PVRSRV_OK)
+ {
+ SysDeinitialise(gpsSysData);
+ gpsSysData = NULL;
+ return eError;
+ }
+
+
SYS_SPECIFIC_DATA_SET(&gsSysSpecificData,
SYS_SPECIFIC_DATA_ENABLE_PCINIT);
@@ -435,6 +492,8 @@ PVRSRV_ERROR SysDeinitialise(SYS_DATA * psSysData)
SysDeinitialiseCommon(gpsSysData);
+ DeinitSGXPCIDev(gpsSysData);
+
if (SYS_SPECIFIC_DATA_TEST
(psSysSpecData, SYS_SPECIFIC_DATA_ENABLE_ENVDATA)) {
eError = OSDeInitEnvData(gpsSysData->pvEnvSpecificData);