Chinaunix首页 | 论坛 | 博客
  • 博客访问: 519260
  • 博文数量: 398
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 14
  • 用 户 组: 普通用户
  • 注册时间: 2013-08-21 16:02
个人简介

嵌入式屌丝

文章分类

全部博文(398)

文章存档

2013年(398)

我的朋友

分类: LINUX

2013-08-21 16:25:28

arm-linux东东nand:前记.

由于刚开始写blog.且本人也只不过是在校的一个学生.难免出错.如果错了请告诉我一下,谢谢

 

,nand 初始化:

环境:linux2.6.26,S3C2440 

LINUXNAND驱动是在DRIVERS/MTD目录中.

Makefile指示 nand 是构架在MTD之上的.

MTD有字驱动,块驱动之分,还有一个是分区.NAND是块驱动.多数的NAND512为一个寻址单位.32512为一个block.这是从Makefile开始

obj-$(CONFIG_MTD)          += mtd.o

mtd-y                           := mtdcore.o mtdsuper.o

mtd-$(CONFIG_MTD_PARTITIONS) += mtdpart.o

obj-$(CONFIG_MTD_CONCAT)  += mtdconcat.o

obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o

obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o

obj-$(CONFIG_MTD_AFS_PARTS)    += afs.o

obj-$(CONFIG_MTD_AR7_PARTS)    += ar7part.o

obj-$(CONFIG_MTD_OF_PARTS)      += ofpart.o

# 'Users' - code which presents functionality to userspace.

obj-$(CONFIG_MTD_CHAR)             += mtdchar.o

obj-$(CONFIG_MTD_BLKDEVS)       += mtd_blkdevs.o

obj-$(CONFIG_MTD_BLOCK)           += mtdblock.o

obj-$(CONFIG_MTD_BLOCK_RO)     += mtdblock_ro.o

obj-$(CONFIG_FTL)           += ftl.o

obj-$(CONFIG_NFTL)         += nftl.o

obj-$(CONFIG_INFTL)        += inftl.o

obj-$(CONFIG_RFD_FTL)          += rfd_ftl.o

obj-$(CONFIG_SSFDC)              += ssfdc.o

obj-$(CONFIG_MTD_OOPS)             += mtdoops.o

nftl-objs         := nftlcore.o nftlmount.o

inftl-objs         := inftlcore.o inftlmount.o

obj-y              += chips/ maps/ devices/ nand/ onenand/

obj-$(CONFIG_MTD_UBI)          += ubi/

看到没有如果定义了CONFIG_MTD_PARTITIONS就说明支持分区.我们所要看的目录以及文件就是mtd.o, mtdpart.o mtd_blkdevs.o

而首先看的是devices 目录下的s3c2410.c这个文件.

module_init(s3c2410_nand_init);

module_exit(s3c2410_nand_exit);

于是从s3c2410_nand_init开始

 

static int __i static struct platform_driver s3c2440_nand_driver = {

       .probe            = s3c2440_nand_probe,

       .remove          = s3c2410_nand_remove,

       .suspend  = s3c24xx_nand_suspend,

       .resume          = s3c24xx_nand_resume,

       .driver            = {

              .name      = "s3c2440-nand",

              .owner    = THIS_MODULE,

       },

};

nit s3c2410_nand_init(void)

{

       printk("S3C24XX NAND Driver, (c) 2004 Simtec Electronics\n");

 

       platform_driver_register(&s3c2412_nand_driver);

       platform_driver_register(&s3c2440_nand_driver);

       return platform_driver_register(&s3c2410_nand_driver);

}

很简单.就是打印一些东西.然后调用platform_driver_register.

所有platform的构架都会调用.probe.但是有一个条件:就是s3c2440_nand_driver遇到了属于它自已的设备.

在很久很久以前设备已经被注册进去了.只是我们的眼睛没有觉察到而已.

linux-2.6.26\arch\arm\plat-s3c24xx\common-smdk.c

static struct mtd_partition smdk_default_nand_part[] = {

       [0] = {

              .name      = "Boot Agent",

              .size = SZ_16K,

              .offset     = 0,

       },

       [1] = {

              .name      = "S3C2410 flash partition 1",

              .offset = 0,

              .size = SZ_2M,

       },

       [2] = {

              .name      = "S3C2410 flash partition 2",

              .offset = SZ_4M,

              .size = SZ_4M,

       },

       [3] = {

              .name      = "S3C2410 flash partition 3",

              .offset     = SZ_8M,

              .size = SZ_2M,

       },

       [4] = {

              .name      = "S3C2410 flash partition 4",

              .offset = SZ_1M * 10,

              .size = SZ_4M,

       },

       [5] = {

              .name      = "S3C2410 flash partition 5",

              .offset     = SZ_1M * 14,

              .size = SZ_1M * 10,

       },

       [6] = {

              .name      = "S3C2410 flash partition 6",

              .offset     = SZ_1M * 24,

              .size = SZ_1M * 24,

       },

       [7] = {

              .name      = "S3C2410 flash partition 7",

              .offset = SZ_1M * 48,

              .size = SZ_16M,

       }

};

 

static struct s3c2410_nand_set smdk_nand_sets[] = {

       [0] = {

              .name             = "NAND",

              .nr_chips = 1,

              .nr_partitions  = ARRAY_SIZE(smdk_default_nand_part),

              .partitions       = smdk_default_nand_part,

             

       },

};

 

/* choose a set of timings which should suit most 512Mbit

 * chips and beyond.

*/

 

static struct s3c2410_platform_nand smdk_nand_info = {

       .tacls              = 20,

       .twrph0          = 60,

       .twrph1          = 20,

       .nr_sets   = ARRAY_SIZE(smdk_nand_sets),

       .sets        = smdk_nand_sets,

};

 

/* devices we initialise */

 

static struct platform_device __initdata *smdk_devs[] = {

       &s3c_device_nand,

       &smdk_led4,

       &smdk_led5,

       &smdk_led6,

       &smdk_led7,

};

platform_add_devices(smdk_devs, ARRAY_SIZE(smdk_devs));

看到没有s3c_device_nand.这就是设备.没有错.

这里有几个结构体: smdk_default_nand_part表示分区.移植的同志们对这个是很敏感的.

smdk_nand_sets表示有几块NAND.

请记着有这么些东西.因为在后面我们会回来.

阅读(494) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~