嵌入式Linux開發(fā)環(huán)境的搭建之:U-Boot移植
(7)加入NandFlash的初始化函數(shù)(board/fs2410/fs2410.c)。
#if(CONFIG_COMMANDSCFG_CMD_NAND)
typedefenum
{
NFCE_LOW,
NFCE_HIGH
}NFCE_STATE;
staticinlinevoidNF_Conf(u16conf)
{
S3C2410_NAND*constnand=S3C2410_GetBase_NAND();
nand->NFCONF=conf;
}
staticinlinevoidNF_Cmd(u8cmd)
{
S3C2410_NAND*constnand=S3C2410_GetBase_NAND();
nand->NFCMD=cmd;
}
staticinlinevoidNF_CmdW(u8cmd)
{
NF_Cmd(cmd);
udelay(1);
}
staticinlinevoidNF_Addr(u8addr)
{
S3C2410_NAND*constnand=S3C2410_GetBase_NAND();
nand->NFADDR=addr;
}
staticinlinevoidNF_SetCE(NFCE_STATEs)
{
S3C2410_NAND*constnand=S3C2410_GetBase_NAND();
switch(s)
{
caseNFCE_LOW:
nand->NFCONF=~(111);
break;
caseNFCE_HIGH:
nand->NFCONF|=(111);
break;
}
}
staticinlinevoidNF_WaitRB(void)
{
S3C2410_NAND*constnand=S3C2410_GetBase_NAND();
while(!(nand->NFSTAT(10)));
}
staticinlinevoidNF_Write(u8data)
{
S3C2410_NAND*constnand=S3C2410_GetBase_NAND();
nand->NFDATA=data;
}
staticinlineu8NF_Read(void)
{
S3C2410_NAND*constnand=S3C2410_GetBase_NAND();
return(nand->NFDATA);
}
staticinlinevoidNF_Init_ECC(void)
{
S3C2410_NAND*constnand=S3C2410_GetBase_NAND();
nand->NFCONF|=(112);
}
staticinlineu32NF_Read_ECC(void)
{
S3C2410_NAND*constnand=S3C2410_GetBase_NAND();
return(nand->NFECC);
}
#endif
/*
*NANDflashinitialization.
*/
#if(CONFIG_COMMANDSCFG_CMD_NAND)
externulongnand_probe(ulongphysadr);
staticinlinevoidNF_Reset(void)
{
inti;
NF_SetCE(NFCE_LOW);
NF_Cmd(0xFF);/*resetcommand*/
for(i=0;i10;i++);/*tWB=100ns.*/
NF_WaitRB();/*wait200~500us;*/
NF_SetCE(NFCE_HIGH);
}
staticinlinevoidNF_Init(void)
{
#defineTACLS0
#defineTWRPH04
#defineTWRPH12
NF_Conf((115)|(014)|(013)|(112)
|(111)|(TACLS8)|(TWRPH04)|(TWRPH10));
/*1111,1xxx,rxxx,rxxx*/
/*En512B4stepECCRnFCE=HtACLStWRPH0tWRPH1*/
NF_Reset();
}
voidnand_init(void)
{
S3C2410_NAND*constnand=S3C2410_GetBase_NAND();
NF_Init();
#ifdefDEBUG
printf(NANDflashprobingat0x%.8lXn,(ulong)nand);
#endif
printf(%4luMBn,nand_probe((ulong)nand)>>20);
}
#endif
(8)修改GPIO配置(board/fs2410/fs2410.c)。
/*setuptheI/Oports*/
gpio->GPACON=0x007FFFFF;
gpio->GPBCON=0x002AAAAA;
gpio->GPBUP=0x000002BF;
gpio->GPCCON=0xAAAAAAAA;
gpio->GPCUP=0x0000FFFF;
gpio->GPDCON=0xAAAAAAAA;
gpio->GPDUP=0x0000FFFF;
gpio->GPECON=0xAAAAAAAA;
gpio->GPEUP=0x000037F7;
gpio->GPFCON=0x00000000;
gpio->GPFUP=0x00000000;
gpio->GPGCON=0xFFEAFF5A;
gpio->GPGUP=0x0000F0DC;
gpio->GPHCON=0x0018AAAA;
gpio->GPHDAT=0x000001FF;
gpio->GPHUP=0x00000656
c語言相關(guān)文章:c語言教程
linux相關(guān)文章:linux教程
評論