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

📄 init.c

📁 三星2440原版bsp
💻 C
📖 第 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 SMDK2440X board initialization code.
//
#include <bsp.h>
 
#define RETAILMSG(cond,printf_exp)	  ((cond)?(NKDbgPrintfW printf_exp),1:0)

#define NOT_FIXEDUP (DWORD)-1
DWORD dwOEMDrWatsonSize = NOT_FIXEDUP;

#ifdef DVS_EN
//---------------------------------------------------------------------------
// Variables for DVS
static int CurrVoltage;
extern volatile int CurrentState;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Function for DVS
void ChangeVoltage(int);
int GetCurrentVoltage(void);
// ----------------------------------------------------------------------------
#endif

static void InitDisplay(void);
extern const BYTE ScreenBitmap[];
UINT32 g_oalIoCtlClockSpeed;

static void InitWLAN(void);

void Init_BspArgs(void);
void Port_Init(void);


//------------------------------------------------------------------------------
//
//  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()
{
	UINT32 logMask_Backup;
	extern DWORD CEProcessorType;	// From nkarm.h in the private tree.
#ifdef DVS_EN
	volatile S3C2440X_IOPORT_REG *s2440IOP = (S3C2440X_IOPORT_REG *)OALPAtoVA(S3C2440X_BASE_REG_PA_IOPORT, FALSE);
#endif
    	volatile S3C2440X_INTR_REG *pIntr = (S3C2440X_INTR_REG*)OALPAtoVA(S3C2440X_BASE_REG_PA_INTR, FALSE);
#ifdef DVS_EN
#if (DVS_METHOD == 3)
	volatile S3C2440X_PWM_REG *g_pPWMRegs = (S3C2440X_PWM_REG*)OALPAtoUA(S3C2440X_BASE_REG_PA_PWM, FALSE);
    	UINT32 sysIntr = SYSINTR_NOP;
    	UINT32 irq;
	UINT32 tcon;
#endif
#endif
	g_oalIoCtlClockSpeed = S3C2440X_FCLK;
	


    	// Lie about the Processor Type (we do this so that the visual C tools work)
	CEProcessorType = PROCESSOR_STRONGARM;
	
	logMask_Backup = g_oalLogMask;
	OALLogSetZones( (1<<OAL_LOG_ERROR) | (1<<OAL_LOG_WARN) | (1<<OAL_LOG_FUNC) );

	RETAILMSG(1,(TEXT("CEProcessorType = 0x%x\r\n"),CEProcessorType));
	OALMSG(OAL_FUNC, (L"+OEMInit\r\n"));
	RETAILMSG(1,(TEXT("FCLK: %d, HCLK: %d, PCLK: %d, Prescaler: %d\r\n"),S3C2440X_FCLK, S3C2440X_HCLK, S3C2440X_PCLK, PRESCALER));
	// Set memory size for DrWatson kernel support
 	if (dwOEMDrWatsonSize != NOT_FIXEDUP) 
 	{
        	dwNKDrWatsonSize = dwOEMDrWatsonSize;      // set size of reserved memory for Watson dump
 	}
 
 	pOEMIsProcessorFeaturePresent = OALIsProcessorFeaturePresent;

	// 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
	);
	
	//Initialize GPIO
	Port_Init();
	
	// Initialize interrupts
	if (!OALIntrInit()) {
		OALMSG(OAL_ERROR, (
			L"ERROR: OEMInit: failed to initialize interrupts\r\n"
		));
	}

	// Initialize system clock
	OALTimerInit(RESCHED_PERIOD, OEM_COUNT_1MS, 0);

	// Initialize the KITL connection if required
	RETAILMSG(1, (TEXT("OALKitlStart() \n\r")));
	OALKitlStart();


	// DonGo Added.
	InitDisplay();

	InitWLAN();

	Init_BspArgs();	
	OALMSG(OAL_FUNC, (L"-OEMInit\r\n"));
       
	OALLogSetZones(logMask_Backup);
#ifdef DVS_EN
#if (Eval_Probe == 1)
	s2440IOP->MISCCR = (s2440IOP->MISCCR & ~(0x7 << 8)) | (0x3 << 8);		// CLKSEL1,     011 -> HCLK
	s2440IOP->MISCCR = (s2440IOP->MISCCR & ~(0x7 << 4)) | (0x4 << 4);		// CLKSEL0,     100 -> PCLK
	s2440IOP->GPHCON = (s2440IOP->GPHCON & ~(0x3 << 18)) | (0x2 << 18);		// GPH9 -> CLKOUT0
	s2440IOP->GPHCON = (s2440IOP->GPHCON & ~(0x3 << 20)) | (0x2 << 20);		// GPH10 -> CLKOUT1
#endif //(Eval_Probe == 1)	

#if (DVS_METHOD == 3)
	CurrentState = Active;
#endif
#endif
}

//------------------------------------------------------------------------------
#define pBSPArgs					((BSP_ARGS *) IMAGE_SHARE_ARGS_UA_START)
void Init_BspArgs(void)
{
	// Initialize the BSP args structure.
	//
	if (
		pBSPArgs->header.signature  != OAL_ARGS_SIGNATURE ||
		pBSPArgs->header.oalVersion != OAL_ARGS_VERSION   ||
		pBSPArgs->header.bspVersion != BSP_ARGS_VERSION
	) 
	{
		OALMSG(OAL_FUNC, (L"Init_BspArgs.\n"));
		memset(pBSPArgs, 0, sizeof(BSP_ARGS));
		pBSPArgs->header.signature	   = OAL_ARGS_SIGNATURE;
		pBSPArgs->header.oalVersion	  = OAL_ARGS_VERSION;
		pBSPArgs->header.bspVersion	  = BSP_ARGS_VERSION;
		pBSPArgs->fUpdateMode = FALSE ;
		pBSPArgs->fUldrReboot = FALSE ; 
	}
	RETAILMSG(1, (TEXT("pBSPArgs->header.signature(%x)=%x\n"), OAL_ARGS_SIGNATURE, pBSPArgs->header.signature)); 
	RETAILMSG(1, (TEXT("pBSPArgs->header.oalVersion(%x)=%x\n"), OAL_ARGS_VERSION, pBSPArgs->header.oalVersion)); 
	RETAILMSG(1, (TEXT("pBSPArgs->header.bspVersion(%x)=%x\n"), BSP_ARGS_VERSION, pBSPArgs->header.bspVersion)); 
	RETAILMSG(1, (TEXT("pBSPArgs->fUpdateMode=%x\n"), pBSPArgs->fUpdateMode)); 
	RETAILMSG(1, (TEXT("pBSPArgs->kitl.flags=%x\n"), pBSPArgs->kitl.flags)); 

}

static void InitWLAN(void)
{
	volatile int i;
	
	volatile S3C2440X_IOPORT_REG *s2440IOP = (S3C2440X_IOPORT_REG *)OALPAtoVA(S3C2440X_BASE_REG_PA_IOPORT, FALSE);
	volatile S3C2440X_MEMCTRL_REG *s2440MEM = (S3C2440X_MEMCTRL_REG *)OALPAtoVA(S3C2440X_BASE_REG_PA_MEMCTRL, FALSE);
	volatile S3C2440X_INTR_REG  *s2440INTR = (S3C2440X_INTR_REG *)OALPAtoVA(S3C2440X_BASE_REG_PA_INTR, FALSE);


	// BANK5 for SMDK2440  
	volatile S3C2440X_BANK5_REG  *s2440BANK5 = (S3C2440X_BANK5_REG *)OALPAtoVA(0x28000000, FALSE);

	s2440MEM->BWSCON = (s2440MEM->BWSCON&~(0xf<<20)|(0xd<<20));	// nWAIT enable
	s2440MEM->BANKCON5 = (WLAN_Tacs<<13)
										+(WLAN_Tcos<<11)
										+(WLAN_Tacc<<8)
										+((WLAN_Tcoh+1)<<6)
		                                                        +(WLAN_Tah<<4)
		                                                        +(WLAN_Tacp<<2)
		                                                        +(WLAN_PMC);

	s2440IOP->GPGCON = (s2440IOP->GPGCON&~(0x3<<4));
	s2440IOP->GPGCON = (s2440IOP->GPGCON&~(0x3<<6));
	s2440IOP->GPGCON = (s2440IOP->GPGCON&~(0x3<<22));

	s2440IOP->GPGCON = (s2440IOP->GPGCON|(0x2<<4));   // EINT - #IRQ
	s2440IOP->GPGCON = (s2440IOP->GPGCON|(0x1<<6));   // RESET
	s2440IOP->GPGCON = (s2440IOP->GPGCON|(0x1<<22));  // #PD

	RETAILMSG(1, (TEXT("-WLANInit - BWSCON : %x BANKCON5 : %x GPGCON : %x  \n\r"), s2440MEM->BWSCON, s2440MEM->BANKCON7, s2440IOP->GPGCON));
		
	s2440IOP->GPGUP = (s2440IOP->GPGUP|(0x1<<2));   // input - #IRQ
	
	s2440IOP->GPGDAT = (s2440IOP->GPGDAT&~(0x1<<2))|(0x0<<2);  // #IRQ data clear
	s2440IOP->GPGDAT = (s2440IOP->GPGDAT&~(0x1<<11))|(0x1<<11);  // #PD set to HIGH
	s2440IOP->GPGDAT = (s2440IOP->GPGDAT&~(0x1<<3))|(0x0<<3);    // RESET set to LOW
	s2440INTR->INTMSK &= ~(1<<5);	// Enable EINT8~23
	s2440IOP->EINTMASK &= ~(1<<10);	// Enable EINT10
	s2440IOP->EXTINT1 = (s2440IOP->EXTINT1&~(0x7<<8)) |(0x0<<8);    // LOW level EINT
	
	for(i = 0; i <= 100; i++)
	;
	
	s2440IOP->GPGDAT = (s2440IOP->GPGDAT|(0x1<<3));    // RESET set to HIGH
	
	//jwkim
	for(i=0; i<=100 ; i++)
	;
	s2440IOP->GPGDAT = (s2440IOP->GPGDAT&(0x0<<3));    // RESET set to LOW , jwkim
	RETAILMSG(1, (TEXT("WLAN: RESET back to LOW\r\n")));	

	
	i = 0;
	while(!(s2440IOP->GPGDAT&0x4))
	{
		i++;
		if(i > 1000000)
		{
			RETAILMSG(1, (TEXT("WLAN IRQ ERROR!\r\n")));
			break;
		}
	}
	RETAILMSG(1, (TEXT("Init WLAN OK!\r\n")));
}

/*
	@func   void | InitDisplay | Initializes the LCD controller and displays a splashscreen image.
	@rdesc  N/A.
	@comm	
	@xref   
*/
static void InitDisplay(void)
{
	volatile S3C2440X_IOPORT_REG *s2440IOP = (S3C2440X_IOPORT_REG *)OALPAtoVA(S3C2440X_BASE_REG_PA_IOPORT, FALSE);

⌨️ 快捷键说明

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