S5PV210之Nand flash驱动编写
时间:12-10
来源:互联网
点击:
- static struct mtd_partition s5p_nand_partions[] = {
- [0] = {
- .name = "bootloader",
- .offset = 0,
- .size = SZ_1M,
- },
- [1] = {
- .name = "kernel",
- .offset = MTDPART_OFS_APPEND,
- .size = 5*SZ_1M,
- },
- [2] = {
- .name = "rootfs",
- .offset = MTDPART_OFS_APPEND,
- .size = MTDPART_SIZ_FULL,
- },
- };
- static void s5p_nand_select_chip(struct mtd_info *mtd, int chipnr){
- if(chipnr == -1){
- s5p_nand_regs->nfcont |= (1<<1);
- }
- else{
- s5p_nand_regs->nfcont &= ~(1<<1);
- }
- }
- static void s5p_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
- {
- if (ctrl & NAND_CLE){
- s5p_nand_regs->nfcmmd = cmd;
- }
- else{
- s5p_nand_regs->nfaddr = cmd;
- }
- }
- static int s5p_nand_ready(struct mtd_info *mtd){
- return (s5p_nand_regs->nfstat & 0x1);
- }
- static int s5p_nand_probe(struct platform_device *pdev){
- int ret = 0;
- struct resource *mem;
- //硬件部分初始化
- mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!mem) {
- dev_err(&pdev->dev, "can't get I/O resource mem\n");
- return -ENXIO;
- }
- s5p_nand_regs = (struct s5p_nand_regs *)ioremap(mem->start, resource_size(mem));
- if (s5p_nand_regs == NULL) {
- dev_err(&pdev->dev, "ioremap failed\n");
- ret = -EIO;
- goto err_exit;
- }
- s5p_nand_ecc = (struct s5p_nand_ecc *)ioremap(0xB0E20000, sizeof(struct s5p_nand_ecc));
- if(s5p_nand_ecc == NULL){
- dev_err(&pdev->dev, "ioremap failed\n");
- ret = -EIO;
- goto err_iounmap;
- }
- s5p_nand_clk = clk_get(&pdev->dev, "nand");
- if(s5p_nand_clk == NULL){
- 嵌入式系统的定义与发展历史(11-15)
- 嵌入式系统亲密接触(11-22)
- 嵌入式系统设计中的USB OTG方案(02-01)
- 嵌入式线控驾驶系统开发过程中设计和测试考虑(02-02)
- 一个典型的嵌入式系统设计和实现 (02-02)
- DDR SDRAM在嵌入式系统中的应用(02-07)