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

📄 init.c

📁 S3C2443 WINCE6.0 BSP
💻 C
📖 第 1 页 / 共 3 页
字号:
//
// 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; // woo
void ConfigureGPIO(void);

UINT32 g_oalIoCtlClockSpeed;

#ifdef DVS_EN
#define ARM_VDD		1
#define	INT_VDD		0
//-------------------------------------------
// Variables for DVS
static int CurrVoltage;
extern volatile int CurrentState;
extern volatile int PrevState;
extern volatile int NextState;

//---------------------------------------------------------------------------
// Function for DVS
void ChangeVoltage(int);
int GetCurrentVoltage(void);
void Max1718_Set(int pwr, int voltage);  // add 060624
void Max1718_Init(void);  // add 060624
// ----------------------------------------------------------------------------
#endif

//------------------------------------------------------------------------------
//
//  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()
{

    OALLogSetZones(initialOALLogZones); 
    OALMSG(OAL_FUNC, (L"+OEMInit\r\n"));
    
	g_oalIoCtlClockSpeed = S3C2443_FCLK;
    CEProcessorType=PROCESSOR_STRONGARM;
	
	
		Max1718_Init();	
    // 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));
    
        // Check and initialize the BSP Args area
    //
    OALArgsInit((BSP_ARGS *) IMAGE_SHARE_ARGS_UA_START);

    // Check clean boot flag in BSP Args area
    //
    {
      // This is the global shared Args flag
      BOOL *bCleanBootFlag = (BOOL*) OALArgsQuery(BSP_ARGS_QUERY_CLEANBOOT);

      if(*bCleanBootFlag)
      {
        OALMSG(1, (TEXT("OEM: Force clean boot.\r\n")));

        // Clear the flag so that we don't get here in the next boot unless it is set again.
        *bCleanBootFlag = FALSE;

        // Tell filesys.exe that we want a clean boot.
        NKForceCleanBoot();

        // Also set the hive and storage clean flags if not already set
        {
          BOOL *bHiveCleanFlag  = (BOOL*) OALArgsQuery(BSP_ARGS_QUERY_HIVECLEAN);
          BOOL *bFormatPartFlag = (BOOL*) OALArgsQuery(BSP_ARGS_QUERY_FORMATPART);

          *bHiveCleanFlag  = TRUE;
          *bFormatPartFlag = TRUE;
        }
      }
    }
    
    // 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);
   
	ConfigureGPIO();

	InitDisplay();

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

//	OALInitUSBHost();

        // Make high-res Monte Carlo profiling available to the kernel
    g_pOemGlobal->pfnProfileTimerEnable = OEMProfileTimerEnable;
    g_pOemGlobal->pfnProfileTimerDisable = OEMProfileTimerDisable;


    // Initialize the KITL connection if required
    KITLIoctl(IOCTL_KITL_STARTUP, NULL, 0, NULL, 0, NULL);
#ifdef DVS_EN
#if (DVS_METHOD == 4 || DVS_METHOD == 5)
	CurrentState = Active;
	CurrVoltage = HIGHVOLTAGE;
#endif
#endif

    OALMSG(1, (L"-OEMInit\r\n"));
}

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

void delayLoop(int count) 
{ 
	volatile int j; 
	for(j = 0; j < count; j++)  ; 
}
/*
void	OALInitUSBHost()
{
	volatile S3C2443_CLKPWR_REG *s2443PWR = (S3C2443_CLKPWR_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_CLOCK_POWER, FALSE);
	volatile S3C2443_IOPORT_REG *s2443IOP = (S3C2443_IOPORT_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_IOPORT, FALSE);
	
	s2443PWR->HCLKCON |= (1<<11);
	//s2443PWR->HCLKCON &= ~(1<<11);
	s2443PWR->CLKDIV1 = (s2443PWR->CLKDIV1 & ~(0x3<<4))|(1<<4);
	s2443PWR->SCLKCON |= (1<<1);
	//s2443PWR->SCLKCON &= ~(1<<1);
	
	
	s2443IOP->MISCCR &= ~(1<<12);  // USBD is 0 ,normal mode ,1 is suspend mode /
	s2443PWR->PWRCFG |= (1<<4);
	
	//USB device 2.0 must reset like bellow , 1st phy reset and after at least 10us, func_reset & host reset     
	//phy reset can reset bellow registers.
    s2443PWR->USB_RSTCON = (0x0<<2)|(0x0<<1)|(0x1<<0);//Function 2.0 S/W reset, Host 1.1 S/W reset,PHY 2.0 S/W reset
    delayLoop(1000); // phy reset must be asserted for at 10us 
    s2443PWR->USB_RSTCON = (0x0<<2)|(0x1<<1)|(0x0<<0);//Function 2.0 S/W reset, Host 1.1 S/W reset,PHY 2.0 S/W reset
    s2443PWR->USB_RSTCON = (0x0<<2)|(0x0<<1)|(0x0<<0);//Function 2.0 S/W reset, Host 1.1 S/W reset,PHY 2.0 S/W reset

	//s2443PWR->USB_PHYCTRL &= ~(0x1<<1);
	s2443PWR->USB_PHYCTRL = (0x0<<3)|(0x0<<2)|(0x0<<1)|(0x0<<0);  //48Mhz,Oscillator,External X-tal,device
    s2443PWR->USB_PHYPWR = (0x0<<31)|(0x0<<4)|(0x0<<3)|(0x0<<2)|(0x0<<1)|(0x0<<0); 
    //48Mhz clock on ,PHY2.0 analog block power on,XO block power on,XO block power in suspend mode,PHY 2.0 Pll power on ,suspend signal for save mode disable 
    s2443PWR->USB_CLKCON = (0x0<<31)|(0x0<<2)|(0x0<<1)|(0x0<<0);
    
    //RETAILMSG(1,(TEXT("HCLKCON : 0x%X\n"),s2443PWR->HCLKCON));
    //RETAILMSG(1,(TEXT("PCLKCON : 0x%X\n"),s2443PWR->PCLKCON));
    //RETAILMSG(1,(TEXT("SCLKCON : 0x%X\n"),s2443PWR->SCLKCON));
}
*/


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);

⌨️ 快捷键说明

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