⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 init.c.svn-base

📁 这是三星的2443的wince的bootloader
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//------------------------------------------------------------------------------
//
//  File:  init.c
//
//  Samsung SMDK2443 board initialization code.
//
#include <bsp.h>

//#include "bitmap.c" 
#include "display.h"
#include "DisplaySample_320_240.h"

void 	OALInitUSBHost();
static void InitDisplay(void);
extern DWORD CEProcessorType;
void ConfigureGPIO(void);

UINT32 g_oalIoCtlClockSpeed;

#ifdef DVS_EN
//-------------------------------------------
//@{ Variables for DVS
static int CurrVoltage[2];			// for arm and int
extern volatile int CurrentState;
//@}

//---------------------------------------------------------------------------
//{@ Function for DVS
//
BOOL ChangeVoltage(int which, int *voltage_table);	
int GetCurrentVoltage(int which);
//@}

// ----------------------------------------------------------------------------
#endif
void Max1718_Set(int pwr, int voltage);  // add 060624
void Max1718_Init(int);  // add 060624


//------------------------------------------------------------------------------
//
//  Global:  g_oalRtcResetTime
//
//  RTC init time after a RTC reset has occured.
//
SYSTEMTIME g_oalRtcResetTime = {2005, 5, 5, 27, 12, 0, 0, 0};

//------------------------------------------------------------------------------
//
//  Function:  OEMInit
//
//  This is Windows CE OAL initialization function. It is called from kernel
//  after basic initialization is made.
//
void OEMInit()
{
//	volatile S3C2443_CLKPWR_REG *s2443PWR = (S3C2443_CLKPWR_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_CLOCK_POWER, FALSE);
//	volatile S3C2443_SDRAM_REG *s2443DRAM = (S3C2443_SDRAM_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_SDRAM, FALSE);

    OALMSG(OAL_FUNC, (L"+OEMInit\r\n"));
    
	g_oalIoCtlClockSpeed = S3C2443_FCLK;
    CEProcessorType = PROCESSOR_STRONGARM;
	


    // Set memory size for DrWatson kernel support
    dwNKDrWatsonSize = 128 * 1024;

    //NKForceCleanBoot();	// clean registry and set new, later must be erased.	- 06.06.30 JJG

    // Initilize cache globals
    OALCacheGlobalsInit();

    OALLogSerial(
        L"DCache: %d sets, %d ways, %d line size, %d size\r\n", 
        g_oalCacheInfo.L1DSetsPerWay, g_oalCacheInfo.L1DNumWays,
        g_oalCacheInfo.L1DLineSize, g_oalCacheInfo.L1DSize
    );
    OALLogSerial(
        L"ICache: %d sets, %d ways, %d line size, %d size\r\n", 
        g_oalCacheInfo.L1ISetsPerWay, g_oalCacheInfo.L1INumWays,
        g_oalCacheInfo.L1ILineSize, g_oalCacheInfo.L1ISize
    );
    
    RETAILMSG(1,(TEXT("FCLK:%d, HCLK:%d, PCLK:%d\n"), S3C2443_FCLK, S3C2443_HCLK, S3C2443_PCLK));
    
    ConfigureGPIO();
    
    // Initialize interrupts
    if (!OALIntrInit()) {
        OALMSG(OAL_ERROR, (
            L"ERROR: OEMInit: failed to initialize interrupts\r\n"
        ));
    }

    // Initialize system clock
    // OALTimerInit(1, (25-1), 0);	// 25 = S3C2443_PCLK/250/16/1000 
    OALTimerInit(RESCHED_PERIOD, (OEM_COUNT_1MS ), 0);
   

	InitDisplay();

    // Initialize the KITL connection if required
    OALKitlStart();

//	user_test();


#ifdef DVS_EN
	Max1718_Init(TRUE);			
	CurrentState = Active;	
	{
		int voltage_set[2] = HIGH_V_SET;
		CurrVoltage[0] = voltage_set[0];
		CurrVoltage[1] = voltage_set[1];
	}
#endif
/*
	RETAILMSG(1,(TEXT("MPLLCON=0x%08X\n"),s2443PWR->MPLLCON));
	RETAILMSG(1,(TEXT("HCLKCON=0x%08X\n"),s2443PWR->HCLKCON));
	RETAILMSG(1,(TEXT("PCLKCON=0x%08X\n"),s2443PWR->PCLKCON));
	RETAILMSG(1,(TEXT("SCLKCON=0x%08X\n"),s2443PWR->SCLKCON));
	
	RETAILMSG(1,(TEXT("BANKCFG=0x%08X\n"),s2443DRAM->BANKCFG));
	RETAILMSG(1,(TEXT("BANKCON1=0x%08X\n"),s2443DRAM->BANKCON1));
	RETAILMSG(1,(TEXT("BANKCON2=0x%08X\n"),s2443DRAM->BANKCON2));	
	RETAILMSG(1,(TEXT("BANKCON3=0x%08X\n"),s2443DRAM->BANKCON3));	
	RETAILMSG(1,(TEXT("REFRESH=0x%08X\n"),s2443DRAM->REFRESH));	
*/
    OALMSG(OAL_FUNC, (L"-OEMInit\r\n"));
}

//------------------------------------------------------------------------------

void delayLoop(int count) 
{ 
	volatile int j; 
	for(j = 0; j < count; j++)  ; 
}


void Write_LDI_LTV350(int address, int data)
{
	volatile S3C2443_IOPORT_REG *s2443IOP = (S3C2443_IOPORT_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_IOPORT, FALSE);
	volatile S3C2443_LCD_REG    *s2443LCD = (S3C2443_LCD_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_LCD, FALSE);	
 	UINT8	dev_id_code=0x1D;
        int     j;
	unsigned char DELAY=50;
		

	
	LCD_DEN_Hi; 		//	EN = High					CS high
	LCD_DCLK_Hi;							//	SCL High
	LCD_DSERI_Hi;							//	Data Low

	delayLoop(DELAY);

	LCD_DEN_Lo; 		//	EN = Low				CS Low
	delayLoop(DELAY);
	
	for (j = 5; j >= 0; j--)
	{	
		LCD_DCLK_Lo;							//	SCL Low

		if ((dev_id_code >> j) & 0x0001)	// DATA HIGH or LOW
		{
			LCD_DSERI_Hi;		
		}
		else
		{
			LCD_DSERI_Lo;
		}

		delayLoop(DELAY);

		LCD_DCLK_Hi;			// CLOCK = High
		delayLoop(DELAY);

	}
	
	// RS = "0" : index data
	LCD_DCLK_Lo;			// CLOCK = Low
	LCD_DSERI_Lo;
	delayLoop(DELAY);
	LCD_DCLK_Hi;			// CLOCK = High
	delayLoop(DELAY);

	// Write
	LCD_DCLK_Lo;			// CLOCK = Low
	LCD_DSERI_Lo;
	delayLoop(DELAY);
	LCD_DCLK_Hi;			// CLOCK = High
	delayLoop(DELAY);

	for (j = 15; j >= 0; j--)
	{
		LCD_DCLK_Lo;							//	SCL Low

		if ((address >> j) & 0x0001)	// DATA HIGH or LOW
		{
			LCD_DSERI_Hi;		
		}
		else
		{
			LCD_DSERI_Lo;
		}

		delayLoop(DELAY);

		LCD_DCLK_Hi;			// CLOCK = High
		delayLoop(DELAY);

	}
	LCD_DSERI_Hi;
	delayLoop(DELAY);
	
	LCD_DEN_Hi; 				// EN = High
	delayLoop(DELAY*10);

	LCD_DEN_Lo; 		//	EN = Low				CS Low
	delayLoop(DELAY);
	
	for (j = 5; j >= 0; j--)
	{	
		LCD_DCLK_Lo;							//	SCL Low

		if ((dev_id_code >> j) & 0x0001)	// DATA HIGH or LOW
		{
			LCD_DSERI_Hi;		
		}
		else
		{
			LCD_DSERI_Lo;
		}

		delayLoop(DELAY);

		LCD_DCLK_Hi;			// CLOCK = High
		delayLoop(DELAY);

	}
	
	// RS = "1" instruction data
	LCD_DCLK_Lo;			// CLOCK = Low
	LCD_DSERI_Hi;
	delayLoop(DELAY);
	LCD_DCLK_Hi;			// CLOCK = High
	delayLoop(DELAY);

	// Write
	LCD_DCLK_Lo;			// CLOCK = Low
	LCD_DSERI_Lo;
	delayLoop(DELAY);
	LCD_DCLK_Hi;			// CLOCK = High
	delayLoop(DELAY);

	for (j = 15; j >= 0; j--)
	{
		LCD_DCLK_Lo;							//	SCL Low

		if ((data >> j) & 0x0001)	// DATA HIGH or LOW
		{
			LCD_DSERI_Hi;		
		}
		else
		{
			LCD_DSERI_Lo;
		}

		delayLoop(DELAY);

		LCD_DCLK_Hi;			// CLOCK = High
		delayLoop(DELAY);

	}
	
	LCD_DEN_Hi; 				// EN = High
	delayLoop(DELAY);

}

#define LTV350 (TRUE)

void InitLDI_LTV350(void)
{	
    	volatile S3C2443_IOPORT_REG *s2443IOP = (S3C2443_IOPORT_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_IOPORT, FALSE);
    	volatile S3C2443_LCD_REG    *s2443LCD = (S3C2443_LCD_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_LCD, FALSE);	
		volatile S3C2443_CLKPWR_REG *s2443PWR = (S3C2443_CLKPWR_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_CLOCK_POWER, FALSE);    	
		
	// enable EPLL CLOCK for LCD
	s2443PWR->SCLKCON |= (1<<10);

	// LCD module reset
	s2443IOP->GPBDAT |= (1<<(LCD_nRESET));
	s2443IOP->GPBDAT &= ~(1<<(LCD_nRESET)); // goes to LOW

	// delay about 5ms
	delayLoop(LCD_DELAY_1MS*10);	
	s2443IOP->GPBDAT |= (1<<(LCD_nRESET));  // goes to HIGH

		
	//SET_CONFIG_PORT( spi1)
	s2443IOP->GPLCON &= ~(((3<<(LCD_DEN_BIT*2))) | ((3<<(LCD_DCLK_BIT*2))) | ((3<<(LCD_DSERI_BIT*2))));	
	s2443IOP->GPLCON |= (((1<<(LCD_DEN_BIT*2))) | ((1<<(LCD_DCLK_BIT*2))) | ((1<<(LCD_DSERI_BIT*2))));
	// pull-up pull-down disable
	s2443IOP->GPLUDP &= ~(((3<<(LCD_DEN_BIT*2))) | ((3<<(LCD_DCLK_BIT*2))) | ((3<<(LCD_DSERI_BIT*2))));	
#ifdef EVT1
	s2443IOP->GPLUDP |= (((1<<(LCD_DEN_BIT*2))) | ((1<<(LCD_DCLK_BIT*2))) | ((1<<(LCD_DSERI_BIT*2))));
#else
	s2443IOP->GPLUDP |= (((2<<(LCD_DEN_BIT*2))) | ((2<<(LCD_DCLK_BIT*2))) | ((2<<(LCD_DSERI_BIT*2))));
#endif
	// delay about 5ms
	delayLoop(LCD_DELAY_1MS*10);	
		
	LCD_DEN_Hi;
	LCD_DCLK_Hi;
	LCD_DSERI_Hi;	

	///////////////////////////////////////////////////////////////////
	// Init_Lcd_Function
	//////////////////////////////////////////////////////////////////
#if LTV350
	Write_LDI_LTV350(0x01,0x001d);	
	Write_LDI_LTV350(0x02,0x0000);    
   	Write_LDI_LTV350(0x03,0x0000);    
   	Write_LDI_LTV350(0x04,0x0000);
   	Write_LDI_LTV350(0x05,0x50a3);
   	Write_LDI_LTV350(0x06,0x0000);
   	Write_LDI_LTV350(0x07,0x0000);
   	Write_LDI_LTV350(0x08,0x0000);
   	Write_LDI_LTV350(0x09,0x0000);
   	Write_LDI_LTV350(0x0a,0x0000);
   	Write_LDI_LTV350(0x10,0x0000);
   	Write_LDI_LTV350(0x11,0x0000);
   	Write_LDI_LTV350(0x12,0x0000);
   	Write_LDI_LTV350(0x13,0x0000);
   	Write_LDI_LTV350(0x14,0x0000);
   	Write_LDI_LTV350(0x15,0x0000);
   	Write_LDI_LTV350(0x16,0x0000);
   	Write_LDI_LTV350(0x17,0x0000);
   	Write_LDI_LTV350(0x18,0x0000);
   	Write_LDI_LTV350(0x19,0x0000);
#else
	Write_LDI_LTV350(0x09,0x0000);
#endif
	///////////////////////////////////////////////////////////////////
	// Power On Reset Display off State
	//////////////////////////////////////////////////////////////////
	//Write_LDI_LTV350(0x09,0x0000);

	// delay about 10ms
	delayLoop(LCD_DELAY_1MS*10);
	
	///////////////////////////////////////////////////////////////////
	// Power Setting Function 1
	//////////////////////////////////////////////////////////////////
#if LTV350
	Write_LDI_LTV350(0x09,0x4055);
	Write_LDI_LTV350(0x0a,0x0000);
#else
	Write_LDI_LTV350(0x09,0x4055);
	Write_LDI_LTV350(0x0a,0x2000);
#endif

	// delay about 10ms
	delayLoop(LCD_DELAY_1MS*10);
	
	/////////////////////////////////////////////////////////////////////
	// Power Setting 2
	/////////////////////////////////////////////////////////////////////
#if LTV350
	Write_LDI_LTV350(0x0a,0x2000);
#else
	Write_LDI_LTV350(0x09,0x4055);
#endif

	// delay about 50ms
	delayLoop(LCD_DELAY_1MS*50);
	
	///////////////////////////////////////////////////////////////////
	// Instruction Setting
	///////////////////////////////////////////////////////////////////
#if LTV350
	Write_LDI_LTV350(0x01,0x409d);
	Write_LDI_LTV350(0x02,0x0204);
	Write_LDI_LTV350(0x03,0x2100);
	Write_LDI_LTV350(0x04,0x1000);
	Write_LDI_LTV350(0x05,0x5003);
	Write_LDI_LTV350(0x06,0x0009);	//vbp
	Write_LDI_LTV350(0x07,0x000f);	//hbp
	Write_LDI_LTV350(0x08,0x0800);
	Write_LDI_LTV350(0x10,0x0000);
	Write_LDI_LTV350(0x11,0x0000);
	Write_LDI_LTV350(0x12,0x000f);
	Write_LDI_LTV350(0x13,0x1f00);
	Write_LDI_LTV350(0x14,0x0000);
	Write_LDI_LTV350(0x15,0x0000);
	Write_LDI_LTV350(0x16,0x0000);
	Write_LDI_LTV350(0x17,0x0000);
	Write_LDI_LTV350(0x18,0x0000);
	Write_LDI_LTV350(0x19,0x0000);
#else
	Write_LDI_LTV350(0x01,0x409d);
	Write_LDI_LTV350(0x02,0x0204);
	Write_LDI_LTV350(0x03,0x0100);
	Write_LDI_LTV350(0x04,0x3000);
	Write_LDI_LTV350(0x05,0x4003);
	Write_LDI_LTV350(0x06,0x0009);	//vbp
	Write_LDI_LTV350(0x07,0x000f);	//hbp
	Write_LDI_LTV350(0x08,0x0c00);
	Write_LDI_LTV350(0x10,0x0103);
	Write_LDI_LTV350(0x11,0x0301);
	Write_LDI_LTV350(0x12,0x1f0f);
	Write_LDI_LTV350(0x13,0x1f0f);
	Write_LDI_LTV350(0x14,0x0707);
	Write_LDI_LTV350(0x15,0x0307);
	Write_LDI_LTV350(0x16,0x0707);
	Write_LDI_LTV350(0x17,0x0000);
	Write_LDI_LTV350(0x18,0x0004);
	Write_LDI_LTV350(0x19,0x0000);
#endif
	
	
	// delay about 2 frames
	delayLoop(LCD_DELAY_1MS*50);
	

	///////////////////////////////////////////////////////////////////
	// Display On Sequence
	///////////////////////////////////////////////////////////////////
#if LTV350
	Write_LDI_LTV350(0x09,0x4a55);
	Write_LDI_LTV350(0x0a,0x2000);	
#else
	Write_LDI_LTV350(0x09,0x4a55);
	Write_LDI_LTV350(0x05,0x5003);	

#endif
 
}

static void InitDisplay(void)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -