微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > S5PV210(TQ210)学习笔记——Nand flash驱动编写

S5PV210(TQ210)学习笔记——Nand flash驱动编写

时间:11-28 来源:互联网 点击:

  1. nand_chip->hip->cmd_ctrl=s5p_md_ctrl;
  2. nand_chip->IO_ADDR_R=&s5p_nand_regs->nfdata;
  3. nand_chip->IO_ADDR_W=&s5p_nand_regs->nfdata;
  4. nand_chip->dev_ready=s5p_nand_ready;
  5. nand_chip->ecc.mode=NAND_ECC_SOFT;
  6. s5p_mtd_info->priv=nand_chip;
  7. s5p_mtd_info->owner=THIS_MODULE;
  8. //扫描Nandflash设备
  9. if(nand_scan(s5p_mtd_info,1)){
  10. dev_dbg(&pdev->dev,"nandscanerror");
  11. gotoerr_free_info;
  12. }
  13. //添加分区信息
  14. ret=mtd_device_parse_register(s5p_mtd_info,NULL,NULL,s5p_nand_partions,ARRAY_SIZE(s5p_nand_partions));
  15. if(!ret)
  16. return0;
  17. err_free_info:
  18. kfree(s5p_mtd_info);
  19. err_free_chip:
  20. kfree(nand_chip);
  21. err_clk_put:
  22. clk_disable(s5p_nand_clk);
  23. clk_put(s5p_nand_clk);
  24. err_iounmap:
  25. //if(s5p_nand_ecc==NULL)
  26. //iounmap(s5p_nand_ecc);
  27. if(s5p_nand_regs==NULL)
  28. iounmap(s5p_nand_regs);
  29. err_exit:
  30. returnret;
  31. }
  32. staticints5p_nand_remove(structplatform_device*pdev){
  33. nand_release(s5p_mtd_info);
  34. kfree(s5p_mtd_info);
  35. kfree(nand_chip);
  36. clk_disable(s5p_nand_clk);
  37. clk_put(s5p_nand_clk);
  38. if(s5p_nand_regs==NULL)
  39. iounmap(s5p_nand_regs);
  40. return0;
  41. }
  42. staticstructplatform_drivers5p_nand_drv={
  43. .driver={
  44. .owner=THIS_MODULE,
  45. .name="s5p-nand",
  46. },
  47. .probe=s5p_nand_probe,
  48. .remove=s5p_nand_remove,
  49. };
  50. module_platform_driver(s5p_nand_drv);
  51. MODULE_LICENSE("GPL");


源码都在上面,具体的原理还是参考视频或者其他资料,这里就不多说了,如果有任何问题,欢迎留言讨论。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top