Linux下的nandflash驱动分析(1)——基于S3C6410平台
源码主要在S3c_nand.c (linux2.6.28\drivers\mtd\nand)文件中。
相关阅读:
1、模块加载和卸载
module_init(s3c_nand_init);
module_exit(s3c_nand_exit);
static void __exit s3c_nand_exit(void)
{
platform_driver_unregister(&s3c2450_nand_driver);
platform_driver_unregister(&s3c6400_nand_driver);
platform_driver_unregister(&s3c6410_nand_driver);
platform_driver_unregister(&s5pc100_nand_driver);
}
static int __init s3c_nand_init(void)
{
printk("S3C NAND Driver, (c) 2008 Samsung Electronics\n");
platform_driver_register(&s3c2450_nand_driver);
platform_driver_register(&s3c6400_nand_driver);
platform_driver_register(&s3c6410_nand_driver);我们关系的部分
return platform_driver_register(&s5pc100_nand_driver);
}
对应的platform_device如下所示:
static struct resource s3c_nand_resource[] = {
[0] = {
.start = S3C64XX_PA_NAND,
.end = S3C64XX_PA_NAND + S3C64XX_SZ_NAND - 1,
.flags = IORESOURCE_MEM,
}
};
struct platform_device s3c_device_nand = {
.name = "s3c-nand",
.id = -1,
.num_resources = ARRAY_SIZE(s3c_nand_resource),
.resource = s3c_nand_resource,
};
对应的platform_driver如下所示:
static struct platform_driver s3c6410_nand_driver = {
.probe = s3c6410_nand_probe,
.remove = s3c_nand_remove,
.suspend = s3c_nand_suspend,
.resume = s3c_nand_resume,
.driver = {
.name = "s3c6410-nand",
.owner = THIS_MODULE,
},
};
有没有感觉到上面有什么不对?平台设备的驱动名和设备名应该是一样的,可现在不一样了。不过在下面这个函数中:进行了修正。
static void __init smdk6410_map_io(void)
{
s3c_device_nand.name = "s3c6410-nand";
...............
}