Esempio n. 1
0
//------------------------------------------------------------------------------
//
//  Function:  disable_lcd_backlight
//
//  This function disables the backlight for the LCD controller
//
UINT32 disable_lcd_backlight( void )
{
    HANDLE hTwl;

     //OALMSG(OAL_INFO, (L"disable_lcd_backlight+\r\n"));
    // Enable LEDA on TPS659XX
    hTwl = TWLOpen();

#ifdef BSP_EVM2
	if(!IsLVDSMode())
		TWLWriteByteReg(hTwl, TWL_LEDEN, 0x00);
#else
    // The hardware design is completely backwards.  In order
    // to disable the LED control signal, the LEDPWM signal must 
    // be enabled 100%
    // Set LEDAON, LEDAPWM
    TWLWriteByteReg(hTwl, TWL_LEDEN, 0x11);
    // Set PWM registers to same value to trigger 100% duty cycle
    TWLWriteByteReg(hTwl, TWL_PWMAOFF, 0x00);
    TWLWriteByteReg(hTwl, TWL_PWMAON, 0x00);
#endif
    
    TWLClose(hTwl);
     //OALMSG(OAL_INFO, (L"disable_lcd_backlight-\r\n"));
    return ERROR_SUCCESS;
}
BOOL ValidateHandle()
{
	if ( g_hTwl == NULL)
	{
		g_hTwl = TWLOpen();
	}
	return (g_hTwl != NULL);
}
Esempio n. 3
0
//------------------------------------------------------------------------------
//
//  Function:  enable_lcd_backlight
//
//  This function enables the backlight for the LCD controller
//
UINT32 enable_lcd_backlight( void )
{
    void* hTwl;
    
     //OALMSG(OAL_INFO, (L"enable_lcd_backlight+\r\n"));

    // Enable LEDA on TPS659XX
    hTwl = TWLOpen();

#ifdef BSP_EVM2
    TWLWriteByteReg(hTwl, TWL_LEDEN, 0x11);
    // Set PWM registers to same value to trigger 100% duty cycle
    //TWLWriteByteReg(hTwl, TWL_PWMAOFF, 0x00);
    //TWLWriteByteReg(hTwl, TWL_PWMAON, 0x00);
	if(!IsLVDSMode())
	{
		TWLWriteByteReg(hTwl, TWL_PWMAOFF, 0x20);
		TWLWriteByteReg(hTwl, TWL_PWMAON, 0x01);
	}
	else
	{
		TWLWriteByteReg(hTwl, TWL_PWMAOFF, 0x7F);
		TWLWriteByteReg(hTwl, TWL_PWMAON, 0x7E);
	}
#else
    // The hardware design is completely backwards.  
    // In order to get 100% brightness, the LEDPWM must 
    // be disabled.
    // Clear LEDAON, LEDAPWM
    TWLWriteByteReg(hTwl, TWL_LEDEN, 0x00);
#endif    
    TWLClose(hTwl);
    
     //OALMSG(OAL_INFO, (L"enable_lcd_backlight-\r\n"));
    return ERROR_SUCCESS;
}
Esempio n. 4
0
//------------------------------------------------------------------------------
//
//  Function:  OALIoCtlHalInitRTC
//
//  This function is called by WinCE OS to initialize the time after boot. 
//  Input buffer contains SYSTEMTIME structure with default time value.
//
//
BOOL OALIoCtlHalInitRTC( UINT32 code, 
						 VOID *pInBuffer, 
						 UINT32 inSize, 
						 VOID *pOutBuffer, 
						 UINT32 outSize, 
						 UINT32 *pOutSize
                        )
{
    BOOL            rc = FALSE;
    SYSTEMTIME      *pGivenTime = (LPSYSTEMTIME) pInBuffer;
    UCHAR           bcdTime[6];
    UCHAR           status;
    UCHAR           secure;

    UNREFERENCED_PARAMETER(pOutSize);
    UNREFERENCED_PARAMETER(outSize);
    UNREFERENCED_PARAMETER(pOutBuffer);
    UNREFERENCED_PARAMETER(inSize);
    UNREFERENCED_PARAMETER(code);

    OALMSG(OAL_TIMER && OAL_FUNC, (L"+OALIoCtlHalInitRTC()\r\n"));

   
    // Initialize RTC critical section
    InitializeCriticalSection(&s_rtc.cs);

    // Set CPU GPIO_64 (T2 MSECURE) to be output/high (unsecure)
    // This allows write access to the T2 RTC calendar/time registers
    // OMAP35XX GP only
    if( dwOEMHighSecurity == OEM_HIGH_SECURITY_GP )
    {
        BSPSetT2MSECURE(TRUE);
    }

    // First read RTC status from Triton 
    s_rtc.hTWL = TWLOpen();
    if (s_rtc.hTWL == NULL)
	{
        OALMSG(OAL_ERROR, (L" OALIoCtlHalInitRTC(): Failed to open Triton\r\n"));
        goto cleanUp;
	}

    // Read secure registers for secure hash
    status = 0;

    TWLReadByteReg(s_rtc.hTWL, TWL_SECURED_REG_A, &secure);
    status |= secure;

    TWLReadByteReg(s_rtc.hTWL, TWL_SECURED_REG_B, &secure);
    status |= secure;

    TWLReadByteReg(s_rtc.hTWL, TWL_SECURED_REG_C, &secure);
    status |= secure;

    TWLReadByteReg(s_rtc.hTWL, TWL_SECURED_REG_D, &secure);
    status |= secure;


    OALMSG(OAL_TIMER && OAL_FUNC, (L" OALIoCtlHalInitRTC():  RTC TWL_SECURED_REG_= 0x%x\r\n", status));

#if 1 // brian
    // Not needed for CE embedded, only need to reset RTC if TWL/TPS PMIC is reset
    // Check for a clean boot of device - if so, reset date/time to system default (LTK2026)
    //pColdBoot = OALArgsQuery(OAL_ARGS_QUERY_COLDBOOT);
    //if ((pColdBoot != NULL) && *pColdBoot)
    //    {
	OALMSG(OAL_TIMER && OAL_FUNC, (L" OALIoCtlHalInitRTC():  Clean boot, reset date time\r\n"));
	status = 0;
    //    }
#endif
		
    // Start RTC when it isn't running
    if (status == 0 && pGivenTime != NULL)
	{
        OALMSG(OAL_TIMER && OAL_FUNC, (L" OALIoCtlHalInitRTC():  Resetting RTC\r\n"));

        // Write power_up and alarm bits to clear power up flag (and any interrupt flag)
        TWLWriteByteReg(s_rtc.hTWL, TWL_RTC_STATUS_REG, TWL_RTC_STATUS_POWER_UP|TWL_RTC_STATUS_ALARM);

        //  Convert system time to BCD
        bcdTime[5] = BIN2BCD(pGivenTime->wYear - RTC_BASE_YEAR_MIN);
        bcdTime[4] = BIN2BCD(pGivenTime->wMonth);
        bcdTime[3] = BIN2BCD(pGivenTime->wDay);
        bcdTime[2] = BIN2BCD(pGivenTime->wHour);
        bcdTime[1] = BIN2BCD(pGivenTime->wMinute);
        bcdTime[0] = BIN2BCD(pGivenTime->wSecond);

        //  Initialize RTC with given values
        TWLWriteByteReg(s_rtc.hTWL, TWL_YEARS_REG,  bcdTime[5]);
        TWLWriteByteReg(s_rtc.hTWL, TWL_MONTHS_REG, bcdTime[4]);
        TWLWriteByteReg(s_rtc.hTWL, TWL_DAYS_REG,   bcdTime[3]);
        TWLWriteByteReg(s_rtc.hTWL, TWL_HOURS_REG,  bcdTime[2]);
        TWLWriteByteReg(s_rtc.hTWL, TWL_MINUTES_REG, bcdTime[1]);
        TWLWriteByteReg(s_rtc.hTWL, TWL_SECONDS_REG, bcdTime[0]);

        //  Enable RTC
        TWLWriteByteReg(s_rtc.hTWL, TWL_RTC_CTRL_REG, TWL_RTC_CTRL_RUN);

        //  Write fake hash to secure regs
        TWLWriteByteReg(s_rtc.hTWL, TWL_SECURED_REG_A, 0xAA);
        TWLWriteByteReg(s_rtc.hTWL, TWL_SECURED_REG_B, 0xBB);
        TWLWriteByteReg(s_rtc.hTWL, TWL_SECURED_REG_C, 0xCC);
        TWLWriteByteReg(s_rtc.hTWL, TWL_SECURED_REG_D, 0xDD);

        //  Convert given time initialization date/time to FILETIME
        NKSystemTimeToFileTime(pGivenTime, (FILETIME*)&s_rtc.baseFiletime);

        //  Set a default value for base offset
        s_rtc.baseOffset = 0;

        //  Save off base offset to the backup regs
        WriteBaseOffset( &s_rtc.baseOffset ); 
	}
    else
	{
        SYSTEMTIME  baseSystemTime;

        OALMSG(OAL_TIMER && OAL_FUNC, (L" OALIoCtlHalInitRTC():  Getting RTC\r\n"));

        //  Set get time flag            
        TWLReadByteReg(s_rtc.hTWL, TWL_RTC_CTRL_REG, &status);

        status |= TWL_RTC_CTRL_RUN | TWL_RTC_CTRL_GET_TIME;
        TWLWriteByteReg(s_rtc.hTWL, TWL_RTC_CTRL_REG, status);

        //  Get date and time from RTC
        TWLReadByteReg(s_rtc.hTWL, TWL_YEARS_REG, &bcdTime[5]);
        TWLReadByteReg(s_rtc.hTWL, TWL_MONTHS_REG, &bcdTime[4]);
        TWLReadByteReg(s_rtc.hTWL, TWL_DAYS_REG, &bcdTime[3]);
        TWLReadByteReg(s_rtc.hTWL, TWL_HOURS_REG, &bcdTime[2]);
        TWLReadByteReg(s_rtc.hTWL, TWL_MINUTES_REG, &bcdTime[1]);
        TWLReadByteReg(s_rtc.hTWL, TWL_SECONDS_REG, &bcdTime[0]);

        //  Convert current RTC date/time to FILETIME
        baseSystemTime.wYear    = BCD2BIN(bcdTime[5]) + RTC_BASE_YEAR_MIN;
        baseSystemTime.wMonth   = BCD2BIN(bcdTime[4]);
        baseSystemTime.wDay     = BCD2BIN(bcdTime[3]);
        baseSystemTime.wHour    = BCD2BIN(bcdTime[2]);
        baseSystemTime.wMinute  = BCD2BIN(bcdTime[1]);
        baseSystemTime.wSecond  = BCD2BIN(bcdTime[0]);
        baseSystemTime.wMilliseconds = 0;

        NKSystemTimeToFileTime(&baseSystemTime, (FILETIME*)&s_rtc.baseFiletime);

        //  Read the offset from the backup regs
        ReadBaseOffset( &s_rtc.baseOffset ); 
	}        


    OALMSG(OAL_TIMER && OAL_FUNC, (L" OALIoCtlHalInitRTC():  RTC = %s\r\n", HWTimeToString(bcdTime)));


    // Now update RTC state values
    s_rtc.initialized   = TRUE;
    s_rtc.baseTickCount = OEMGetTickCount();


    //  Success
    rc = TRUE;


cleanUp:
    OALMSG(OAL_TIMER && OAL_FUNC, (L"-OALIoCtlHalInitRTC() rc = %d\r\n", rc));
    return rc;
}
Esempio n. 5
0
//------------------------------------------------------------------------------
//
//  Function:  OEMPlatformInit
//
//  This function provide platform initialization functions. It is called
//  from boot loader after OEMDebugInit is called.  Note that boot loader
//  BootloaderMain is called from  s/init.s code which is run after reset.
//
BOOL 
OEMPlatformInit(
    )
{
    OMAP_GPTIMER_REGS *pTimerRegs;
    UINT32 CpuRevision, version;
    HANDLE hTwl,hGPIO;
    static UCHAR allocationPool[512];
    static const PAD_INFO ebootPinMux[] = {
            DSS_PADS
            GPIO_PADS
			USBOTG_PADS
            END_OF_PAD_ARRAY
    };
    static const PAD_INFO ebootPinMux_37XX[] = {
            DSS_PADS_37XX
            GPIO_PADS_37XX
	     	USBOTG_PADS
            END_OF_PAD_ARRAY
    };
    
    OALLocalAllocInit(allocationPool,sizeof(allocationPool));

    // Get processor and companion chip versions
	g_CPUFamily = CPU_FAMILY_OMAP35XX;
    CpuRevision = Get_CPUVersion();
    version = CPU_REVISION(CpuRevision);
    g_CPUFamily = CPU_FAMILY(CpuRevision);

	// Set GPTIMER1 regs pointer
	pTimerRegs = OALPAtoUA(OMAP_GPTIMER1_REGS_PA);

    if(g_CPUFamily == CPU_FAMILY_DM37XX)
    {
        ConfigurePadArray(ebootPinMux_37XX);
    }
    else
    {
        ConfigurePadArray(ebootPinMux);
    }
    //OALLogSetZones( 
    //           (1<<OAL_LOG_VERBOSE)  |
    //           (1<<OAL_LOG_INFO)     |
    //           (1<<OAL_LOG_ERROR)    |
    //           (1<<OAL_LOG_WARN)     |
    //           (1<<OAL_LOG_FUNC)     |
    //           (1<<OAL_LOG_IO)     |
    //           0);

    OALLog(
        L"\r\nTexas Instruments Windows CE EBOOT for OMAP35xx/37xx, "
        L"Built %S at %S\r\n", __DATE__, __TIME__
        );
    OALLog(
        L"EBOOT Version %d.%d, BSP " BSP_VERSION_STRING L"\r\n", 
        EBOOT_VERSION_MAJOR, EBOOT_VERSION_MINOR        
        );

    // Soft reset GPTIMER1
    OUTREG32(&pTimerRegs->TIOCP, SYSCONFIG_SOFTRESET);
    // While until done
    while ((INREG32(&pTimerRegs->TISTAT) & GPTIMER_TISTAT_RESETDONE) == 0);
    // Enable posted mode
    OUTREG32(&pTimerRegs->TSICR, GPTIMER_TSICR_POSTED);
    // Start timer
    OUTREG32(&pTimerRegs->TCLR, GPTIMER_TCLR_AR|GPTIMER_TCLR_ST);
    
	// Enable device clocks used by the bootloader
    EnableDeviceClocks(OMAP_DEVICE_GPIO1,TRUE);
    EnableDeviceClocks(OMAP_DEVICE_GPIO2,TRUE);
    EnableDeviceClocks(OMAP_DEVICE_GPIO3,TRUE);
    EnableDeviceClocks(OMAP_DEVICE_GPIO4,TRUE);
    EnableDeviceClocks(OMAP_DEVICE_GPIO5,TRUE);
    EnableDeviceClocks(OMAP_DEVICE_GPIO6,TRUE);

    // configure i2c devices
    OALI2CInit(OMAP_DEVICE_I2C1);
    OALI2CInit(OMAP_DEVICE_I2C2);
    OALI2CInit(OMAP_DEVICE_I2C3);

    GPIOInit();
    // Note that T2 accesses must occur after I2C initialization
    hTwl = TWLOpen();
    hGPIO = GPIOOpen(); 
    
    
    // Clear Reset on ethernet controller        
    GPIOSetBit(hGPIO,LAN9115_RESET_GPIO);            
    GPIOSetMode(hGPIO, LAN9115_RESET_GPIO,GPIO_DIR_OUTPUT);

	//rst usb hub
	GPIOClrBit(hGPIO,13);            
    GPIOSetMode(hGPIO, 13,GPIO_DIR_OUTPUT);
	OALStall(10000);
	GPIOSetBit(hGPIO,13);
	OALStall(1000);
	GPIOClrBit(hGPIO,13);  

    

    OALLog(L"\r\nTI OMAP%x Version 0x%08x (%s)\r\n", CPU_ID(CpuRevision), CPU_REVISION(CpuRevision),        
        version == CPU_FAMILY_35XX_REVISION_ES_1_0 ? L"ES1.0" :
        version == CPU_FAMILY_35XX_REVISION_ES_2_0 ? L"ES2.0" :
        version == CPU_FAMILY_35XX_REVISION_ES_2_1 ? L"ES2.1" :
        version == CPU_FAMILY_35XX_REVISION_ES_2_0_CRC ? L"ES2.0, ID determined using CRC" :
        version == CPU_FAMILY_35XX_REVISION_ES_2_1_CRC ? L"ES2.1, ID determined using CRC" :
        version == CPU_FAMILY_35XX_REVISION_ES_3_0 ? L"ES3.0" :
        version == CPU_FAMILY_35XX_REVISION_ES_3_1 ? L"ES3.1" : 
        version == CPU_FAMILY_37XX_REVISION_ES_1_0? L"ES1.0" :
        version == CPU_FAMILY_37XX_REVISION_ES_1_1? L"ES1.1" :
        version == CPU_FAMILY_37XX_REVISION_ES_1_2? L"ES1.2" :
        L"Unknown" );  
    /* Initialize Device Prefix */
    if(g_CPUFamily == CPU_FAMILY_DM37XX)
    {
        gDevice_prefix = BSP_DEVICE_37xx_PREFIX;
    }
    else if (g_CPUFamily == CPU_FAMILY_OMAP35XX)
    {
        gDevice_prefix = BSP_DEVICE_35xx_PREFIX;
    }
    else
    {
        OALLog(L"INFO: UnKnown CPU family:%d....\r\n", g_CPUFamily);
        gDevice_prefix = BSP_DEVICE_35xx_PREFIX;
    }

    version = TWLReadIDCode(hTwl);

    OALLog(L"TPS659XX Version 0x%02x (%s)\r\n", version,
        version == 0x00 ? L"ES1.0" : 
        version == 0x10 ? L"ES1.1" : 
        version == 0x20 ? L"ES1.2" : 
        version == 0x30 ? L"ES1.3" : L"Unknown" );
		
    g_ecctype = (UCHAR)dwEbootECCtype;

    // Done
    return TRUE;
}
Esempio n. 6
0
//------------------------------------------------------------------------------
//
//  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, &regval, sizeof(regval));
    regval = 0x07 << 5;
    TWLWriteRegs(pDevice->hTWL, TWL_LK_PTV_REG, &regval, sizeof(regval));
    regval = (UINT8)pDevice->debounceCount & 0x3F;
    TWLWriteRegs(pDevice->hTWL, TWL_KEY_DEB_REG, &regval, 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;
}
Esempio n. 7
0
//------------------------------------------------------------------------------
//
//  Function:  OEMPlatformInit
//
//  This function provide platform initialization functions. It is called
//  from boot loader after OEMDebugInit is called.  Note that boot loader
//  BootloaderMain is called from  s/init.s code which is run after reset.
//
BOOL OEMPlatformInit()
{
    OMAP_GPTIMER_REGS *pTimerRegs;
    UINT32 CpuRevision, version;
    HANDLE hTwl,hGPIO;
    static UCHAR allocationPool[512];
    
    /*static const PAD_INFO ebootPinMux[] = {
            DSS_PADS
            GPIO_PADS
			USBOTG_PADS
            END_OF_PAD_ARRAY
    };*/
    static const PAD_INFO ebootPinMux_37XX[] = 
    {
            DSS_PADS_37XX
            GPIO_PADS_37XX
	     	USBOTG_PADS
	     	MCSPI1_PADS                     //Addition to MCSPI1 functional, Ray 13-09-24
            I2C3_PADS                       //Addition to MCSPI1 functional, Ray 13-10-21
            END_OF_PAD_ARRAY
    };
    
    OALLocalAllocInit(allocationPool, sizeof(allocationPool));

    // Get processor and companion chip versions
	g_CPUFamily = CPU_FAMILY_OMAP35XX;
    CpuRevision = Get_CPUVersion();
    version = CPU_REVISION(CpuRevision);
    g_CPUFamily = CPU_FAMILY(CpuRevision);

	// Set GPTIMER1 regs pointer
	pTimerRegs = OALPAtoUA(OMAP_GPTIMER1_REGS_PA);

    //if(g_CPUFamily == CPU_FAMILY_DM37XX)
    //{
	ConfigurePadArray(ebootPinMux_37XX);
    //}
    //else
    //{
    //    ConfigurePadArray(ebootPinMux);
    //}

    OALLog(L"ZEBEX Windows CE EBOOT for Z-2170 plus - Ray Testing"		//Ray 13-07-31 
	//OALLog(L"ZEBEX Windows CE EBOOT for Z-2170 plus - Brain"		
        L"\r\nBuilt %S at %S\r\n", __DATE__, __TIME__ );
    /*OALLog(
        L"EBOOT Version %d.%d, BSP " BSP_VERSION_STRING L"\r\n", 
        EBOOT_VERSION_MAJOR, EBOOT_VERSION_MINOR        
        );*/

    // Soft reset GPTIMER1
    OUTREG32(&pTimerRegs->TIOCP, SYSCONFIG_SOFTRESET);
    // While until done
    while ((INREG32(&pTimerRegs->TISTAT) & GPTIMER_TISTAT_RESETDONE) == 0)
    	;
 
    // Enable posted mode
    OUTREG32(&pTimerRegs->TSICR, GPTIMER_TSICR_POSTED);
    // Start timer
    OUTREG32(&pTimerRegs->TCLR, GPTIMER_TCLR_AR|GPTIMER_TCLR_ST);
    
	// Enable device clocks used by the bootloader
    EnableDeviceClocks(OMAP_DEVICE_GPIO1, TRUE);
    EnableDeviceClocks(OMAP_DEVICE_GPIO2, TRUE);
    EnableDeviceClocks(OMAP_DEVICE_GPIO3, TRUE);
    EnableDeviceClocks(OMAP_DEVICE_GPIO4, TRUE);
    EnableDeviceClocks(OMAP_DEVICE_GPIO5, TRUE);
    EnableDeviceClocks(OMAP_DEVICE_GPIO6, TRUE);

    // configure i2c devices
    OALI2CInit(OMAP_DEVICE_I2C1);
    OALI2CInit(OMAP_DEVICE_I2C2);
    OALI2CInit(OMAP_DEVICE_I2C3);

    GPIOInit();
    // Note that T2 accesses must occur after I2C initialization
    hTwl = TWLOpen();
    hGPIO = GPIOOpen(); 
    
    
    // Clear Reset on ethernet controller        
    //GPIOSetBit(hGPIO,LAN9115_RESET_GPIO);            
    //GPIOSetMode(hGPIO, LAN9115_RESET_GPIO,GPIO_DIR_OUTPUT);
	// test GPIO 
	GPIOClrBit(hGPIO, 136); 	// VIBRATOR
	GPIOSetMode(hGPIO, 136, GPIO_DIR_OUTPUT);
    GPIOClrBit(hGPIO, 16); 		// WLAN_EN
	GPIOSetMode(hGPIO, 16, GPIO_DIR_OUTPUT);
	GPIOClrBit(hGPIO, 15); 		// BT_EN
	GPIOSetMode(hGPIO, 15, GPIO_DIR_OUTPUT);
	GPIOSetBit(hGPIO, 61); 		// BACKLIGHT_EN, Ray
	GPIOSetMode(hGPIO, 61, GPIO_DIR_OUTPUT);

	//Initialization Side key GPIO, Ray 13-08-12
	GPIOSetMode(hGPIO, 114, GPIO_DIR_INPUT);     // SIDE_KEY1(KEY_2_4)
	GPIOSetMode(hGPIO, 115, GPIO_DIR_INPUT);     // SIDE_KEY3(KEY_1_4)

	//Initialization the "MC serial port interface (SPI1)" buses, Ray 13-09-24
    GPIOSetMode(hGPIO, SPI_CS0_PIN, GPIO_DIR_OUTPUT);
    GPIOSetMode(hGPIO, SPI_CLK_PIN, GPIO_DIR_OUTPUT);
    GPIOSetMode(hGPIO, SPI_DOUT_PIN, GPIO_DIR_OUTPUT);
    GPIOSetMode(hGPIO, SPI_DIN_PIN, GPIO_DIR_INPUT);

    //Initialization the "I-suqare-c (i2c3)" buses, Ray 13-10-07
    /*GPIOSetMode(hGPIO, I2C3_SCL_GPIO, INPUT_ENABLED);
    GPIOSetMode(hGPIO, I2C3_SDA_GPIO, INPUT_ENABLED);*/

    /*GPIOSetBit(hGPIO, I2C3_SCL_GPIO); 
    GPIOSetMode(hGPIO, I2C3_SCL_GPIO, GPIO_DIR_OUTPUT);
    GPIOSetBit(hGPIO, I2C3_SDA_GPIO); 
    GPIOSetMode(hGPIO, I2C3_SDA_GPIO, GPIO_DIR_OUTPUT);*/
    

   
	//SPI LCM setup
	/*XX
	GPIOSetBit(hGPIO,184); // PCM_EN serial clock 
	GPIOSetMode(hGPIO, 184, GPIO_PULLUP_ENABLE);
	//GPIOSetMode(hGPIO, 184, GPIO_DIR_OUTPUT);

	GPIOSetBit(hGPIO,185); // PCM_EN serial data
	GPIOSetMode(hGPIO, 185, GPIO_PULLUP_ENABLE);
	//GPIOSetMode(hGPIO, 185, GPIO_DIR_OUTPUT);*/


     OALLog(L"\r\nTI OMAP%x Version 0x%08x (%s)\r\n", CPU_ID(CpuRevision), CPU_REVISION(CpuRevision),        
        version == CPU_FAMILY_35XX_REVISION_ES_1_0 ? L"ES1.0" :
        version == CPU_FAMILY_35XX_REVISION_ES_2_0 ? L"ES2.0" :
        version == CPU_FAMILY_35XX_REVISION_ES_2_1 ? L"ES2.1" :
        version == CPU_FAMILY_35XX_REVISION_ES_2_0_CRC ? L"ES2.0, ID determined using CRC" :
        version == CPU_FAMILY_35XX_REVISION_ES_2_1_CRC ? L"ES2.1, ID determined using CRC" :
        version == CPU_FAMILY_35XX_REVISION_ES_3_0 ? L"ES3.0" :
        version == CPU_FAMILY_35XX_REVISION_ES_3_1 ? L"ES3.1" : 
        version == CPU_FAMILY_37XX_REVISION_ES_1_0? L"ES1.0" :
        version == CPU_FAMILY_37XX_REVISION_ES_1_1? L"ES1.1" :
        version == CPU_FAMILY_37XX_REVISION_ES_1_2? L"ES1.2" :
        L"Unknown" );  

    /* Initialize Device Prefix */
    if(g_CPUFamily == CPU_FAMILY_DM37XX)
    {
        gDevice_prefix = BSP_DEVICE_37xx_PREFIX;
    }
    else if (g_CPUFamily == CPU_FAMILY_OMAP35XX)
    {
        gDevice_prefix = BSP_DEVICE_35xx_PREFIX;
    }
    else
    {
        OALLog(L"INFO: UnKnown CPU family:%d....\r\n", g_CPUFamily);
        gDevice_prefix = BSP_DEVICE_35xx_PREFIX;
    }

    version = TWLReadIDCode(hTwl);

    OALLog(L"TPS659XX Version 0x%02x (%s)\r\n", version,
        version == 0x00 ? L"ES1.0" : 
        version == 0x10 ? L"ES1.1" : 
        version == 0x20 ? L"ES1.2" : 
        version == 0x30 ? L"ES1.3" : L"Unknown" );
		
    g_ecctype = (UCHAR)dwEbootECCtype;

    // Done
    return TRUE;
}
Esempio n. 8
0
//------------------------------------------------------------------------------
//
//  Function:  ADC_Init
//
//  Called by device manager to initialize device.
//
DWORD
ADC_Init(
    LPCTSTR szContext, 
    LPCVOID pBusContext
    )
{
    DWORD rc = (DWORD)NULL;
    Device_t *pDevice;

    UNREFERENCED_PARAMETER(pBusContext);
    UNREFERENCED_PARAMETER(szContext);  

    DEBUGMSG(ZONE_FUNCTION, (
        L"+ADC_Init(%s, 0x%08x)\r\n", szContext, pBusContext
        ));

    // Create device structure
    pDevice = (Device_t *)LocalAlloc(LPTR, sizeof(Device_t));
    if (pDevice == NULL)
        {
        DEBUGMSG(ZONE_ERROR, (L"ERROR: ADC_Init: "
            L"Failed allocate MADC driver structure\r\n"
            ));

        goto cleanUp;
        }

    // Set cookie
    pDevice->cookie = MADC_DEVICE_COOKIE;

    // Initialize critical sections
    InitializeCriticalSection(&pDevice->cs);

    // Open Triton device driver
    pDevice->hTWL = TWLOpen();
    if ( pDevice->hTWL == NULL )
        {
        DEBUGMSG( ZONE_ERROR, (L"ERROR: ADC_Init: "
            L"Failed open Triton device driver\r\n"
            ));
        goto cleanUp;
        }

    // initialize device with registry settings
    if (InitializeDevice(pDevice) == FALSE)
        {
        DEBUGMSG( ZONE_ERROR, (L"ERROR: ADC_Init: "
            L"Failed to initilialize MADC device\r\n"
            ));
        goto cleanUp;
        }

    // Return non-null value
    rc = (DWORD)pDevice;

cleanUp:
    if (rc == 0) ADC_Deinit((DWORD)pDevice);

    DEBUGMSG(ZONE_FUNCTION, (L"-ADC_Init(rc = %d\r\n", rc));
    return rc;
}