Linux内核的Nand驱动流程分析
时间:11-28
来源:互联网
点击:
- FINE_RES_MEM_NAMED((_start),(_size),NULL)
- {
- .start=(S3C_PA_NAND),
- .end=(S3C_PA_NAND)+(SZ_1M)-1,
- .name=(NULL),
- .flags=(IORESOURCE_MEM),
- }
- #defineS3C2410_PA_NAND(0x4E000000)
- #defineS3C24XX_PA_NANDS3C2410_PA_NAND
- #defineS3C_PA_NANDS3C24XX_PA_NAND
也就是说,S3C_PA_NAND是Nand flash寄存器首地址,而SZ_1M明显是个长度,因此,这里的resource实际上是Nand flash寄存器首地址跟接下来的1M空间,可是,Nand的寄存器并没有那么多,这又是为什么呢?这些信息有什么用又在哪里用到了呢?答案很简单,这肯定是给驱动程序使用的了,带着这个疑问我们继续分析代码。定位到/drivers/mtd/nand/s3c2410.c,浏览代码可以看到驱动结构定义
- staticstructplatform_drivers3c24xx_nand_driver={
- .probe=s3c24xx_nand_probe,
- .remove=s3c24xx_nand_remove,
- .suspend=s3c24xx_nand_suspend,
- .resume=s3c24xx_nand_resume,
- .id_table=s3c24xx_driver_ids,
- .driver={
- .name="s3c24xx-nand",
- .owner=THIS_MODULE,
- },
- };
- staticint__inits3c2410_nand_init(void)
- {
- printk("S3C24XXNANDDriver,(c)2004SimtecElectronics");
- returnplatform_driver_register(&s3c24xx_nand_driver);
- }
- staticvoid__exits3c2410_nand_exit(void)
- {
- platform_driver_unregister(&s3c24xx_nand_driver);
- }
- module_init(s3c2410_nand_init);
- module_exit(s3c2410_nand_exit);
- MODULE_LICENSE("GPL");
- MODULE_AUTHOR("BenDooks
"); - MODULE_DESCRIPTION("S3C24XXMTDNANDdriver");
- staticints3c24xx_nand_probe(structplatform_device*pdev)
- {
- structs3c2410_platform_nand*plat=to_nand_plat(pdev);
- enums3c_cpu_typecpu_type;
- structs3c2410_nand_info*info;
- structs3c2410_nand_mtd*nmtd;
- structs3c2410_nand_set*sets;
- structresource*res;
- interr=0;
- intsize;
- intnr_sets;
- intsetno;
- cpu_type=platform_get_device_id(pdev)->driver_data;
- pr_debug("s3c2410_nand_probe(%p)",pdev);
- info=kzalloc(sizeof(*info),GFP_KERNEL);
- if(info==NULL){
- dev_err(&pdev->dev,"nomemoryforflashinfo");
- err=-ENOMEM;
- gotoexit_error;
- }
- platform_set_drvdata(pdev,info);
- spin_lock_init(&info->controller.lock);
- init_waitqueue_head(&info->controller.wq);
- /*gettheclocksourceandenableit*/
- info->clk=clk_get(&pdev->dev,"nand");
- if(IS_ERR(info->clk)){
- dev_err(&pdev->dev,"failedtogetclock");
- err=-ENOENT;
- gotoexit_error;
- }
- s3c2410_nand_clk_set_state(info,CLOCK_ENABLE);
- /*allocateandmaptheresource*/
- /*currentlyweassumewehavetheoneresource*/
- res=pdev->resource;
- size=resource_size(res);
- info->area=request_mem_region(res->start,size,pdev->name);
- if(info->area==NULL){
- dev_err(&pdev->dev,"cannotreserveregisterregion");
- err=-ENOENT;
- gotoexit_error;
- }
- info->device=&pdev->dev;
- info->platform=plat;
- info->regs=ioremap(res->start,size);
- info->cpu_type=cpu_type;
- if(info->regs==NULL){
- dev_err(&pdev->dev,"cannotreserveregisterregion");
- err=-EIO;
- gotoexit_error;
- }
- dev_dbg(&pdev->dev,"mappedregistersat%p",info->regs);
- /*initialisethehardware*/
- err=s3c2410_nand_inithw(info);
- if
Linux内核Nand驱动流程分 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)