//----------------------------------------------------------------------------- BOOL InitializePointers( LPCTSTR szContext, NandDevice_t *pDevice ) { #ifdef BOOT_MODE UNREFERENCED_PARAMETER(szContext); UNREFERENCED_PARAMETER(pDevice); #else PHYSICAL_ADDRESS pa; InitializeCriticalSection(&pDevice->cs); // Read device parameters if (GetDeviceRegistryParams( szContext, pDevice, dimof(g_deviceRegParams), g_deviceRegParams ) != ERROR_SUCCESS) { DEBUGMSG(ZONE_ERROR, (L"ERROR: FMD_Init: " L"Failed read FMD registry parameters\r\n" )); return FALSE; } pa.QuadPart = pDevice->memBase[0]; pDevice->pGpmcRegs = MmMapIoSpace(pa, pDevice->memLen[0], FALSE); if (pDevice->pGpmcRegs == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: FMD_Init: " L"Failed map FMD registers (0x%08x/0x%08x)\r\n", pDevice->memBase[0], pDevice->memLen[0] )); return FALSE; } pa.QuadPart = pDevice->memBase[1]; pDevice->pFifo = (NANDREG*)MmMapIoSpace(pa, pDevice->memLen[1], FALSE); if (pDevice->pFifo == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: FMD_Init: " L"Failed map FMD registers (0x%08x/0x%08x)\r\n", pDevice->memBase[0], pDevice->memLen[0] )); return FALSE; } #endif return TRUE; }
//------------------------------------------------------------------------------ // // Function: HDS_Init // // Called by device manager to initialize device. // DWORD HDS_Init( LPCTSTR szContext, LPCVOID pBusContext ) { DWORD rc = (DWORD)NULL; HeadsetDevice_t *pDevice = NULL; UNREFERENCED_PARAMETER(pBusContext); DEBUGMSG(ZONE_FUNCTION, ( L"+HDS_Init(%s, 0x%08x)\r\n", szContext, pBusContext )); // Create device structure pDevice = (HeadsetDevice_t *)LocalAlloc(LPTR, sizeof(HeadsetDevice_t)); if (pDevice == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: HDS_Init: " L"Failed allocate HDS driver structure\r\n" )); goto cleanUp; } // initialize memory // memset(pDevice, 0, sizeof(HeadsetDevice_t)); // Set cookie & initialize critical section pDevice->cookie = HDS_DEVICE_COOKIE; // Initialize crit section InitializeCriticalSection(&pDevice->cs); // Read device parameters if (GetDeviceRegistryParams( szContext, pDevice, dimof(s_deviceRegParams), s_deviceRegParams) != ERROR_SUCCESS) { DEBUGMSG(ZONE_ERROR, (L"ERROR: HDS_Init: " L"Failed read HDS driver registry parameters\r\n" )); goto cleanUp; } // Open WAV device pDevice->hWAV = CreateFile(L"WAV1:", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if (pDevice->hWAV == INVALID_HANDLE_VALUE) { pDevice->hWAV = NULL; DEBUGMSG(ZONE_WARN, (L"WARN: HDS_Init: Failed open WAV1: device driver\r\n")); } // Open GPIO bus pDevice->hGPIO = GPIOOpen(); if (pDevice->hGPIO == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: HDS_Init: " L"Failed open GPIO bus driver\r\n" )); goto cleanUp; } // Configure GPIO mute as output high GPIOSetMode(pDevice->hGPIO, pDevice->hdstMuteGpio, GPIO_DIR_OUTPUT); GPIOSetBit(pDevice->hGPIO, pDevice->hdstMuteGpio); // Note that the headset detect GPIO pullup and pulldown configuration // is not handled in the \src\boot\twl4030\bsp_twl4020.c file // Configure GPIO headset as input with both edge interrupts GPIOSetMode(pDevice->hGPIO, pDevice->hdstDetGpio, GPIO_DIR_INPUT | GPIO_INT_LOW_HIGH | GPIO_INT_HIGH_LOW); // update plugged-in field pDevice->bPluggedIn = (BOOL)GPIOGetBit(pDevice->hGPIO, pDevice->hdstDetGpio); // Create interrupt event pDevice->hIntrEvent = CreateEvent(NULL, FALSE, FALSE, NULL); if (pDevice->hIntrEvent == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: HDS_Init: " L"Failed create interrupt event\r\n" )); goto cleanUp; } // Associate event with TWL headset interrupt if (!GPIOInterruptInitialize(pDevice->hGPIO, pDevice->hdstDetGpio, &pDevice->dwSysIntr, pDevice->hIntrEvent)) { DEBUGMSG (ZONE_ERROR, (L"ERROR: HDS_Init: " L"Failed associate event with TWL headset interrupt\r\n" )); goto cleanUp; } // Start interrupt service thread pDevice->intrThreadExit = FALSE; pDevice->hIntrThread = CreateThread( NULL, 0, HDS_IntrThread, pDevice, 0,NULL ); if (!pDevice->hIntrThread) { DEBUGMSG (ZONE_ERROR, (L"ERROR: HDS_Init: " L"Failed create interrupt thread\r\n" )); goto cleanUp; } // Set thread priority CeSetThreadPriority(pDevice->hIntrThread, pDevice->priority256); // Return non-null value rc = (DWORD)pDevice; cleanUp: if (rc == 0) { HDS_Deinit((DWORD)pDevice); } DEBUGMSG(ZONE_FUNCTION, (L"-HDS_Init(rc = %d\r\n", rc)); return rc; }
//------------------------------------------------------------------------------ // // Function: I2C_Init // // Called by device manager to initialize device. // DWORD I2C_Init( LPCTSTR szContext, LPCVOID pBusContext ) { DWORD rc = (DWORD)NULL; Device_t *pDevice; UNREFERENCED_PARAMETER(pBusContext); // Create device structure pDevice = (Device_t *)LocalAlloc(LPTR, sizeof(Device_t)); if (pDevice == NULL) { RETAILMSG(ZONE_ERROR, (L"ERROR: I2C_Init: " L"Failed allocate Proxy driver structure\r\n" )); goto cleanUp; } memset(pDevice, 0, sizeof(Device_t)); // Set cookie pDevice->cookie = I2C_DEVICE_COOKIE; // Initialize critical sections InitializeCriticalSection(&pDevice->cs); // Read device parameters if (GetDeviceRegistryParams( szContext, pDevice, dimof(s_deviceRegParams), s_deviceRegParams ) != ERROR_SUCCESS) { DEBUGMSG(ZONE_ERROR, (L"ERROR: I2C_Init: " L"Failed read I2C Proxy driver registry parameters\r\n" )); goto cleanUp; } // get handle to rootbus for notification to dvfs policy // Open clock device pDevice->hParent = CreateFile(L"BUS1:", 0, 0, NULL, 0, 0, NULL); if (pDevice->hParent == INVALID_HANDLE_VALUE) { RETAILMSG(ZONE_ERROR, (L"ERROR: I2C_Init: " L"Failed open parent bus device '%s'\r\n", L"BUS1:" )); pDevice->hParent = NULL; goto cleanUp; } pDevice->devId = SOCGetI2CDeviceByBus(pDevice->index); // Return non-null value rc = (DWORD)pDevice; cleanUp: if (rc == 0) I2C_Deinit((DWORD)pDevice); RETAILMSG(ZONE_FUNCTION, (L"-I2C_Init(rc = %d\r\n", rc)); return rc; }
//------------------------------------------------------------------------------ // // Function: KPD_Init // // Called by device manager to initialize device. // DWORD KPD_Init(LPCTSTR szContext, LPCVOID pBusContext) { DWORD rc = (DWORD)NULL; KPD_DEVICE *pDevice = NULL; PHYSICAL_ADDRESS pa; DEBUGMSG(ZONE_FUNCTION, ( L"+KPD_Init(%s, 0x%08x)\r\n", szContext, pBusContext )); // Create device structure pDevice = (KPD_DEVICE *)LocalAlloc(LPTR, sizeof(KPD_DEVICE)); if (pDevice == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed allocate KDP driver structure\r\n" )); goto cleanUp; } // Set cookie & initialize critical section pDevice->cookie = KPD_DEVICE_COOKIE; InitializeCriticalSection(&pDevice->cs); // Read device parameters if (GetDeviceRegistryParams( szContext, pDevice, dimof(g_deviceRegParams), g_deviceRegParams ) != ERROR_SUCCESS) { DEBUGMSG(ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed read KPD driver registry parameters\r\n" )); pDevice->irqs[0]= -1; pDevice->irqs[1]= 2; pDevice->irqs[2]=(DWORD)NULL; pDevice->irqs[3]=(DWORD)NULL; pDevice->irqs[4]=(DWORD)NULL; pDevice->irqs[5]=(DWORD)NULL; pDevice->irqs[6]=(DWORD)NULL; pDevice->priority256=100; pDevice->samplePeriod=40; pDevice->debounceTime=0x50; pDevice->firstRepeat=500; pDevice->nextRepeat=125; // goto cleanUp; } // map gpio memory space pa.QuadPart = OMAP2420_GPIO1_REGS_PA; pDevice->pGPIO1Regs = (OMAP2420_GPIO_REGS *) MmMapIoSpace(pa, sizeof(OMAP2420_GPIO_REGS), FALSE); if (pDevice->pGPIO1Regs == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: KPD_Init: Failed to map GPIO1 registers\r\n")); goto cleanUp; } pa.QuadPart = OMAP2420_GPIO2_REGS_PA; pDevice->pGPIO2Regs = (OMAP2420_GPIO_REGS *) MmMapIoSpace(pa, sizeof(OMAP2420_GPIO_REGS), FALSE); if (pDevice->pGPIO2Regs == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: KPD_Init: Failed to map GPIO2 registers\r\n")); goto cleanUp; } pa.QuadPart = OMAP2420_GPIO3_REGS_PA; pDevice->pGPIO3Regs = (OMAP2420_GPIO_REGS *) MmMapIoSpace(pa, sizeof(OMAP2420_GPIO_REGS), FALSE); if (pDevice->pGPIO3Regs == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: KPD_Init: Failed to map GPIO3 registers\r\n")); goto cleanUp; } pa.QuadPart = OMAP2420_GPIO4_REGS_PA; pDevice->pGPIO4Regs = (OMAP2420_GPIO_REGS *) MmMapIoSpace(pa, sizeof(OMAP2420_GPIO_REGS), FALSE); if (pDevice->pGPIO4Regs == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: KPD_Init: Failed to map GPIO4 registers\r\n")); goto cleanUp; } // Need to configure the row GPIO's as interrupt sources pDevice->irqs[0] = -1; pDevice->irqs[1] = 2; //pDevice->irqs[2] = IRQ_GPIO_0+88; // row 0 = GPIO88 //pDevice->irqs[3] = IRQ_GPIO_0+89; // row 1 = GPIO89 //pDevice->irqs[4] = IRQ_GPIO_0+124; // row 2 = GPIO124 //pDevice->irqs[5] = IRQ_GPIO_0+11; // row 3 = GPIO11 //pDevice->irqs[6] = IRQ_GPIO_0+6; // row 4 = GPIO6 // Map interrupts if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, pDevice->irqs, sizeof(pDevice->irqs), &pDevice->sysIntr, sizeof(pDevice->sysIntr), NULL )) { DEBUGMSG(ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed map Keyboard Interrupt\r\n" )); goto cleanUp; } else DEBUGMSG(ZONE_INIT, (L"KPD_Init: sysintr = %d",pDevice->sysIntr)); // Enable wakeup from keyboard if required if (pDevice->enableWake != 0) { DEBUGMSG(ZONE_ERROR, (L"Enable keyboard as wakeup source\r\n")); if (!KernelIoControl( IOCTL_HAL_ENABLE_WAKE, &pDevice->sysIntr, sizeof(pDevice->sysIntr), NULL, 0, NULL )) { DEBUGMSG(ZONE_WARN, (L"WARN: KPD_Init: " L"Failed enable keyboard as wakeup source\r\n" )); } } // Create interrupt event pDevice->hIntrEvent = CreateEvent(NULL, FALSE, FALSE, NULL); if (pDevice->hIntrEvent == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed create interrupt event\r\n" )); goto cleanUp; } // Initialize interrupt if (!InterruptInitialize(pDevice->sysIntr, pDevice->hIntrEvent, NULL, 0)) { DEBUGMSG (ZONE_ERROR, (L"ERROR: KPD_Init: " L"InterruptInitialize failed\r\n" )); goto cleanUp; } // Start interrupt service thread if ((pDevice->hIntrThread = CreateThread( NULL, 0, KPD_IntrThread, pDevice, 0,NULL )) == NULL) { DEBUGMSG (ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed create interrupt thread\r\n" )); goto cleanUp; } // Set thread priority CeSetThreadPriority(pDevice->hIntrThread, pDevice->priority256); // Return non-null value rc = (DWORD)pDevice; cleanUp: if (rc == 0) KPD_Deinit((DWORD)pDevice); DEBUGMSG(ZONE_FUNCTION, (L"-KPD_Init(rc = %d\r\n", rc)); return rc; }
//------------------------------------------------------------------------------ // // Function: KPD_Init // // Called by device manager to initialize device. // DWORD KPD_Init(LPCTSTR szContext, LPCVOID pBusContext) { DWORD rc = (DWORD)NULL; KeypadDevice_t *pDevice = NULL; UINT8 regval; UNREFERENCED_PARAMETER(pBusContext); DEBUGMSG(ZONE_FUNCTION, ( L"+KPD_Init(%s, 0x%08x)\r\n", szContext, pBusContext )); // Create device structure pDevice = (KeypadDevice_t *)LocalAlloc(LPTR, sizeof(KeypadDevice_t)); if (pDevice == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed allocate KDP driver structure\r\n" )); goto cleanUp; } memset(pDevice, 0, sizeof(KeypadDevice_t)); // Set cookie & initialize critical section pDevice->cookie = KPD_DEVICE_COOKIE; // Read device parameters if (GetDeviceRegistryParams( szContext, pDevice, dimof(s_deviceRegParams), s_deviceRegParams) != ERROR_SUCCESS) { DEBUGMSG(ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed read KPD driver registry parameters\r\n" )); goto cleanUp; } // Open parent bus pDevice->hTWL = TWLOpen(); if (pDevice->hTWL == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed open TWL bus driver\r\n" )); goto cleanUp; } // Set debounce delay and enable hardware mode regval = TWL_KBD_CTRL_KBD_ON | TWL_KBD_CTRL_NRESET | TWL_KBD_CTRL_NSOFT_MODE; TWLWriteRegs(pDevice->hTWL, TWL_KEYP_CTRL_REG, ®val, sizeof(regval)); regval = 0x07 << 5; TWLWriteRegs(pDevice->hTWL, TWL_LK_PTV_REG, ®val, sizeof(regval)); regval = (UINT8)pDevice->debounceCount & 0x3F; TWLWriteRegs(pDevice->hTWL, TWL_KEY_DEB_REG, ®val, sizeof(regval)); // Create interrupt event pDevice->hIntrEventKeypad = CreateEvent(NULL, FALSE, FALSE, NULL); if (pDevice->hIntrEventKeypad == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed create keypad interrupt event\r\n" )); goto cleanUp; } // Associate event with TWL KP interrupt if (!TWLInterruptInitialize(pDevice->hTWL, TWL_INTR_ITKPI, pDevice->hIntrEventKeypad)) { DEBUGMSG (ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed associate event with TWL KBD interrupt\r\n" )); goto cleanUp; } // Enable KP event if (!TWLInterruptMask(pDevice->hTWL, TWL_INTR_ITKPI, FALSE)) { DEBUGMSG (ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed associate event with TWL KBD interrupt\r\n" )); } // register to be wake-up enabled if (pDevice->enableWake != 0) { TWLWakeEnable(pDevice->hTWL, TWL_INTR_ITKPI, TRUE); } // Start keypad interrupt service thread pDevice->hIntrThreadKeypad = CreateThread( NULL, 0, KPD_IntrThread, pDevice, 0,NULL ); if (!pDevice->hIntrThreadKeypad) { DEBUGMSG (ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed create keypad interrupt thread\r\n" )); goto cleanUp; } if( pDevice->KpLedNum != -1) { // Create keypress notification event pDevice->hKeypressEvent = CreateEvent(NULL, FALSE, FALSE, NULL); if ( pDevice->hKeypressEvent == NULL ) { DEBUGMSG (ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed to create keypress event\r\n" )); goto cleanUp; } // Start interrupt service thread pDevice->hLightThread = CreateThread( NULL, 0, KPD_LightThread, pDevice, 0,NULL ); if (!pDevice->hLightThread) { DEBUGMSG (ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed to create keypad light thread\r\n" )); goto cleanUp; } } // Return non-null value rc = (DWORD)pDevice; cleanUp: if (rc == 0) { KPD_Deinit((DWORD)pDevice); } DEBUGMSG(ZONE_FUNCTION, (L"-KPD_Init(rc = %d\r\n", rc)); return rc; }
//------------------------------------------------------------------------------ // // Function: DMA_Init // // Called by device manager to initialize device. // DWORD DMA_Init( LPCWSTR szContext, LPCVOID pBusContext ) { DWORD rc = (DWORD)NULL; UNREFERENCED_PARAMETER(pBusContext); UNREFERENCED_PARAMETER(szContext); DEBUGMSG(ZONE_FUNCTION, ( L"+DMA_Init(%s, 0x%08x)\r\n", szContext, pBusContext )); // Create device structure Device_t *pDevice = (Device_t *)LocalAlloc(LPTR, sizeof(Device_t)); if (pDevice == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: DMA_Init: " L"Failed allocate DMA controller structure\r\n" )); goto cleanUp; } // initialize memory memset(pDevice, 0, sizeof(Device_t)); // Set cookie pDevice->cookie = DMA_DEVICE_COOKIE; // Initalize critical section InitializeCriticalSection(&pDevice->cs); // Read device parameters if (GetDeviceRegistryParams( szContext, pDevice, dimof(s_deviceRegParams), s_deviceRegParams ) != ERROR_SUCCESS) { DEBUGMSG(ZONE_ERROR, (L"ERROR: DMA_Init: " L"Failed read DMA driver registry parameters\r\n" )); goto cleanUp; } // Retrieve device ID pDevice->SdmaDevice = SOCGetDMADevice(pDevice->SdmaIndex); // Set hardware to full power EnableDeviceClocks(pDevice->SdmaDevice, TRUE); // DMA will be in smart idle mode so we don't need to // ever set the power state of the DMA to D4 // initialize general dma controller if (InitializeDevice(pDevice) == FALSE) { DEBUGMSG (ZONE_ERROR, (L"ERROR: DMA_Init: " L"Failed to initialize device\r\n" )); goto cleanUp; } rc = (DWORD)pDevice; cleanUp: if (rc == 0) DMA_Deinit((DWORD)pDevice); DEBUGMSG(ZONE_FUNCTION, (L"-DMA_Init(rc = %d)\r\n", rc)); return rc; }
HANDLE SMARTREFLEX_InitPolicy( _TCHAR const *szContext ) { RETAILMSG(ZONE_FUNCTION, ( L"+SMARTREFLEX_InitPolicy(0x%08x)\r\n", szContext )); PHYSICAL_ADDRESS PhysAddr; DWORD dwInitOpm = CONSTRAINT_STATE_NULL; // initializt global structure memset(&s_SmartReflexLoadPolicyInfo, 0, sizeof(SmartReflexPolicyInfo_t)); s_SmartReflexLoadPolicyInfo.dwActiveDevices = 0x1; //because LPR starts disabled s_SmartReflexLoadPolicyInfo.bSmartReflexState = FALSE; s_SmartReflexLoadPolicyInfo.nSensingState = STATE_INACTIVE; s_SmartReflexLoadPolicyInfo.bLprModeState = FALSE; // Read policy registry params if (GetDeviceRegistryParams( szContext, &s_SmartReflexLoadPolicyInfo, dimof(g_policyRegParams), g_policyRegParams) != ERROR_SUCCESS) { RETAILMSG(ZONE_ERROR, (L"SMARTREFLEX_InitPolicy: Invalid/Missing " L"registry parameters. Unloading policy\r\n") ); } //create DVFS change notification event s_SmartReflexLoadPolicyInfo.hSmartReflexSensingEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); //start retention optimization thread s_SmartReflexLoadPolicyInfo.hSmartReflexSensingThread = CreateThread( NULL, 0, SmartReflexSensingThread, NULL, 0, NULL ); // Obtain DVFS constraint handler s_SmartReflexLoadPolicyInfo.hDvfsConstraint = PmxSetConstraintById( CONSTRAINT_ID_DVFS, CONSTRAINT_MSG_DVFS_REQUEST, (void*)&dwInitOpm, sizeof(DWORD) ); // register for DVFS change notifications s_SmartReflexLoadPolicyInfo.hDvfsCallback = PmxRegisterConstraintCallback( s_SmartReflexLoadPolicyInfo.hDvfsConstraint, DvfsConstraintCallback, NULL, 0, (HANDLE)&s_SmartReflexLoadPolicyInfo ); //map vdd1 voltage register to virtual memory PhysAddr.QuadPart = PRM_VP1_VOLTAGE; s_VddOptimizationInfo[0].pPrcmRegistryAddress = MmMapIoSpace( PhysAddr, sizeof(UINT32), FALSE ); //map vdd2 voltage register to virtual memory PhysAddr.QuadPart = PRM_VP2_VOLTAGE; s_VddOptimizationInfo[1].pPrcmRegistryAddress = MmMapIoSpace( PhysAddr, sizeof(UINT32), FALSE ); RETAILMSG(ZONE_FUNCTION, (L"-SMARTREFLEX_InitPolicy()\r\n")); return (HANDLE)&s_SmartReflexLoadPolicyInfo; }