S5PV210之Nand flash驱动编写
时间:12-10
来源:互联网
点击:
大家好,又到了天嵌【嵌入式分享】的时间,相对于前几期【嵌入式分享】做的主要是TQ335X开发板的技术分享,本期决定做同是cortex-a8系列的TQ210开发板的技术分享。本期是关于TQ210开发板的Nand flash驱动编写,可能源码部分会比较多,本文由博主girlkoo编写,感谢他的分享。
跟裸机程序一样,S5PV210(TQ210)的Nand flash模块跟S3C2440(TQ2440)的Nand flash模块非常相似,如果不引入ECC,驱动程序的编写也非常简单,我是使用的Linux-3.8.6(Linux-3.8.3也一样)内核,驱动的API函数有些变化,不过原理是相通的,稍微看一下内核源码并参考下其他平台的相关代码就可以自己写出Nand flash驱动了,下面是Nand flash驱动的源码,没有启用ECC,当然,你也可以改成软件ECC,但是我的觉得既然软件ECC不如HWECC快,我就采用硬件ECC吧。
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- struct s5p_nand_regs{
- unsigned long nfconf;
- unsigned long nfcont;
- unsigned long nfcmmd;
- unsigned long nfaddr;
- unsigned long nfdata;
- unsigned long nfmeccd0;
- unsigned long nfmeccd1;
- unsigned long nfseccd;
- unsigned long nfsblk;
- unsigned long nfeblk;
- unsigned long nfstat;
- unsigned long nfeccerr0;
- unsigned long nfeccerr1;
- unsigned long nfmecc0;
- unsigned long nfmecc1;
- unsigned long nfsecc;
- unsigned long nfmlcbitpt;
- };
- struct s5p_nand_ecc{
- unsigned long nfeccconf;
- unsigned long nfecccont;
- unsigned long nfeccstat;
- unsigned long nfeccsecstat;
- unsigned long nfeccprgecc0;
- unsigned long nfeccprgecc1;
- unsigned long nfeccprgecc2;
- unsigned long nfeccprgecc3;
- unsigned long nfeccprgecc4;
- unsigned long nfeccprgecc5;
- unsigned long nfeccprgecc6;
- unsigned long nfeccerl0;
- unsigned long nfeccerl1;
- unsigned long nfeccerl2;
- unsigned long nfeccerl3;
- unsigned long nfeccerl4;
- unsigned long nfeccerl5;
- unsigned long nfeccerl6;
- unsigned long nfeccerl7;
- unsigned long nfeccerp0;
- unsigned long nfeccerp1;
- unsigned long nfeccerp2;
- unsigned long nfeccerp3;
- unsigned long nfeccconecc0;
- unsigned long nfeccconecc1;
- unsigned long nfeccconecc2;
- unsigned long nfeccconecc3;
- unsigned long nfeccconecc4;
- unsigned long nfeccconecc5;
- unsigned long nfeccconecc6;
- };
- static struct nand_chip *nand_chip;
- static struct mtd_info *s5p_mtd_info;
- static struct s5p_nand_regs *s5p_nand_regs;
- static struct s5p_nand_ecc *s5p_nand_ecc;
- static struct clk *s5p_nand_clk;
- 嵌入式系统的定义与发展历史(11-15)
- 嵌入式系统亲密接触(11-22)
- 嵌入式系统设计中的USB OTG方案(02-01)
- 嵌入式线控驾驶系统开发过程中设计和测试考虑(02-02)
- 一个典型的嵌入式系统设计和实现 (02-02)
- DDR SDRAM在嵌入式系统中的应用(02-07)