S5PV210之Nand flash驱动编写
时间:12-10
来源:互联网
点击:
- dev_dbg(&pdev->dev, "get clk failed\n");
- ret = -ENODEV;
- goto err_iounmap;
- }
- clk_enable(s5p_nand_clk);
- s5p_nand_regs->nfconf = (3<<12)|(5<<8)|(3<<4)|(1<<1);
- s5p_nand_regs->nfcont |= 3;
- //分配驱动相关结构体
- nand_chip = (struct nand_chip *)kzalloc(sizeof(struct nand_chip), GFP_KERNEL);
- if(nand_chip == NULL){
- dev_err(&pdev->dev, "failed to allocate nand_chip structure\n");
- ret = -ENOMEM;
- goto err_clk_put;
- }
- s5p_mtd_info = (struct mtd_info *)kzalloc(sizeof(struct mtd_info), GFP_KERNEL);
- if(s5p_mtd_info == NULL){
- dev_err(&pdev->dev, "failed to allocate mtd_info structure\n");
- ret = -ENOMEM;
- goto err_free_chip;
- }
- //设置驱动相关结构体
- nand_chip->select_chip = s5p_nand_select_chip;
- nand_chip->cmd_ctrl = s5p_nand_cmd_ctrl;
- nand_chip->IO_ADDR_R = &s5p_nand_regs->nfdata;
- nand_chip->IO_ADDR_W = &s5p_nand_regs->nfdata;
- nand_chip->dev_ready = s5p_nand_ready;
- nand_chip->ecc.mode = NAND_ECC_SOFT;
- s5p_mtd_info->priv = nand_chip;
- s5p_mtd_info->owner = THIS_MODULE;
- //扫描Nand flash 设备
- if(nand_scan(s5p_mtd_info, 1)){
- dev_dbg(&pdev->dev, "nand scan error\n");
- goto err_free_info;
- }
- //添加分区信息
- ret = mtd_device_parse_register(s5p_mtd_info, NULL, NULL, s5p_nand_partions, ARRAY_SIZE(s5p_nand_partions));
- if(!ret)
- return 0;
- err_free_info:
- kfree(s5p_mtd_info);
- err_free_chip:
- kfree(nand_chip);
- err_clk_put:
- clk_disable(s5p_nand_clk);
- clk_put(s5p_nand_clk);
- err_iounmap:
- //if(s5p_nand_ecc == NULL)
- // iounmap(s5p_nand_ecc);
- if(s5p_nand_regs == NULL)
- iounmap(s5p_nand_regs);
- err_exit:
- return ret;
- }
- static int s5p_nand_remove(struct platform_device *pdev){
- nand_release(s5p_mtd_info);
- kfree(s5p_mtd_info);
- kfree(nan
- 嵌入式系统的定义与发展历史(11-15)
- 嵌入式系统亲密接触(11-22)
- 嵌入式系统设计中的USB OTG方案(02-01)
- 嵌入式线控驾驶系统开发过程中设计和测试考虑(02-02)
- 一个典型的嵌入式系统设计和实现 (02-02)
- DDR SDRAM在嵌入式系统中的应用(02-07)